我已经从我的Twitter帐户中检索到直接消息,并且我想将senderid,发件人屏幕名称和文本存储在mysql数据库表中,以便通过人工智能标记语言引擎进行读取,从而可以相应地进行回复。在我执行程序后,我检查了数据库,并没有从数组中输入任何行,也没有错误消息。

这是我的代码:

$connection = new TwitterOAuth($consumer_key,$consumer_secret, $oAuthToken, $oAuthSecret);

// Get direct message data

$content = $connection ->get('https://api.twitter.com/1/direct_messages.json');

echo '

',print_r($content,true),'

';

function write_messages_to_database() {

require_once('connect_to_database');

$conn = mysql_connect("127.0.0.1", "Diego", "frafra") or die(mysql_error());

mysql_select_db('bot', $conn) or die(mysql_error());

foreach ($content as $directmessage) {

mysql_query("INSERT INTO 'twitter_senders' ('sender_id', 'sender_name'), VALUES ('{$content->id}', '{$content->sender_screen_name}')");

$directmessage_id = mysql_last_insert_id();

foreach ($directmessage->text as $text) {

mysql_query("INSERT INTO 'message_senders' ('message'), VALUES ('{$text->text}')");

}

}

}下面,我只想从中提取id,sender_screen_name中的值

和text。另外,该数组有三个对象,但我只是在示例中粘贴了一个对象。

你怎么看?

Array

(

[0] => stdClass Object

(

[sender_id] => 374504554

[recipient_screen_name] => Infobot2012

[recipient_id] => 428575951

[recipient] => stdClass Object

(

[id] => 428575951

[profile_image_url] =>

[url] =>

[created_at] => Sun Dec 04 22:56:38 +0000 2011

[followers_count] => 3

[default_profile] => 1

[profile_background_color] => C0DEED

[lang] => en

[utc_offset] =>

[name] => Diego Canale

[profile_background_image_url] =>

[location] =>

[profile_link_color] => 0084B4

[listed_count] => 0

[verified] =>

[protected] =>

[profile_use_background_image] => 1

[is_translator] =>

[following] =>

[description] =>

[profile_text_color] => 333333

[statuses_count] => 10

[screen_name] => Infobot2012

[profile_image_url_https] =>

[time_zone] =>

[profile_background_image_url_https] =>

[friends_count] => 14

[default_profile_image] => 1

[contributors_enabled] =>

[profile_sidebar_border_color] => C0DEED

[id_str] => 428575951

[geo_enabled] =>

[favourites_count] => 0

[profile_background_tile] =>

[notifications] =>

[show_all_inline_media] =>

[profile_sidebar_fill_color] => DDEEF6

[follow_request_sent] =>

)

[id_str] => 194550124767227905

[sender] => stdClass Object

(

[id] => 374504554

[profile_image_url] =>

[url] =>

[created_at] => Fri Sep 16 12:46:20 +0000 2011

[followers_count] => 19

[default_profile] => 1

[profile_background_color] => C0DEED

[lang] => en

[utc_offset] =>

[name] => Diego Canale

[profile_background_image_url] =>

[location] => Dublin

[profile_link_color] => 0084B4

[listed_count] => 0

[verified] =>

[protected] =>

[profile_use_background_image] => 1

[is_translator] =>

[following] => 1

[description] =>

[profile_text_color] => 333333

[statuses_count] => 92

[screen_name] => sdiegolo

[profile_image_url_https] =>

[time_zone] =>

[profile_background_image_url_https] =>

[friends_count] => 79

[default_profile_image] =>

[contributors_enabled] =>

[profile_sidebar_border_color] => C0DEED

[id_str] => 374504554

[geo_enabled] =>

[favourites_count] => 1

[profile_background_tile] =>

[notifications] =>

[show_all_inline_media] =>

[profile_sidebar_fill_color] => DDEEF6

[follow_request_sent] =>

)

[created_at] => Mon Apr 23 22:15:38 +0000 2012

[id] => 1.9455012476723E+17

[sender_screen_name] => sdiegolo

[text] => Hello Infobot!

)

将数组存入mysql数据库,将数组值写入mysql数据库相关推荐

  1. mysql 修改表id值_修改数据库中表的id

    展开全部 思路: 1.首先搞清楚所有表636f707962616964757a686964616f31333335333064的主外键关系 2.取消全部表的主键自增标识列,方便你后续的直接修改ID 例 ...

  2. mysql z中文乱码_c#写入Mysql中文显示乱码 解决方法 z

    Linux编程环境 yum -y install gcc gcc-c++ libtool-ltdl libtool-ltdl-devel openssl openssl-devel curl curl ...

  3. mysql双机数据热备份_配置MySQL数据库双机热备份

    1.mysql 数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 mysql 数据库提供了一种主从备份的机制,其实就是把主数据库的所有的数据同时写到备份数据库中.实现 mysql ...

  4. 红帽下安装mysql数据库_[原创]RedHat 安装MySQL数据库

    朋友购买了阿里云的服务器,服务器上自带有CentOS操作系统,但是开发软件需要自己安装,接下来将介绍本地RedHat Linux 5.10虚拟机上搭建Mysql数据库. 一.软件准备 (1)jdk-6 ...

  5. Asterisk realtime 之SIP用户动态写入mysql 数据库

    asterisk  配置默认是文本方式由文件管理,但是对于SIP用户,队列坐席这些数据,保存在 数据库中方便维护,Asterisk 通过realtime 引擎支持此功能,可以把其 配置文件写入 数据库 ...

  6. mysql cast numeric_(转载)mysql decimal、numeric数据类型

    可能做程序的人都知道,float类型是可以存浮点数(即小数类型),但是float有个坏处,当你给定的数据是整数的时候,那么它就以整数给你处理.这样我们在存取货币值的时候自然遇到问题,我的default ...

  7. mysql中decimal类型的使用,MySQL中decimal类型用法的简单介绍

    MySQL中支持浮点数的类型有FLOAT.DOUBLE和DECIMAL类型,DECIMAL 类型不同于FLOAT和DOUBLE,DECIMAL 实际是以串存放的.DECIMAL 可能的最大取值范围与D ...

  8. php 数组存入mysql_PHP将数组存入数据库中的四种方式

    1.implode()和explode()方式 2.print_r()和自定义函数方式 3.serialize()和unserialize()方式 4.json_encode()和json_decod ...

  9. PHP将数组存入数据库中的四种方式

    最近突然遇到了一个问题,如何用PHP将数组存入到数据库中,经过自己的多方查找和研究,总结了以下四种方法: 1.implode()和explode()方式 2.print_r()和自定义函数方式 3.s ...

最新文章

  1. Nat. Mach. Intell.| 机器学习显著降低药物组合筛选成本
  2. 大开眼界!AI在医疗和汽车行业的11个有趣应用
  3. FFMPEG more samples than frame size (avcodec_encode_audio2) 的解决方案
  4. SAP 系统参数设置 RZ10 RZ11
  5. java io 文件路径格式_java中iofile的路径问题,确定一个未知方法所需要的文件路径...
  6. Selenium - CSS Selector
  7. 这是Blazor上传文件的最佳方式吗?
  8. JSF 2.2在30秒内创建一个自定义Hello World组件
  9. python gitlab_Python Gitlab Api 使用方法
  10. c++ 之类的前置声明
  11. 从来不敷面膜的人_女人睡觉前,敷面膜洗还是不洗?很多人都做错了,难怪皮肤总不好...
  12. python导入数据画柱状图代码_在Linux下使用Python的matplotlib绘制数据图的教程
  13. XenApp_XenDesktop_7.6实战篇之十二:组策略配置
  14. python写二进制文件_初学Python写二进制文件
  15. stm32模块化编程
  16. 第114课:SparkStreaming+Kafka+Spark SQL+TopN+Mysql+KafkaOffsetMonitor电商广告点击综合案例实战(详细内幕版本)
  17. Spring 事务源码(6)—createTransactionIfNecessary处理事务属性并尝试创建事务【两万字】
  18. 排错的时候不要“想当然”
  19. 一分钟建立自己单位的故障报修平台
  20. 【STM32F429】第6章 ThreadX GUIX上手之STM32F429 DMA2D加速

热门文章

  1. 重磅!可以发朋友圈和搜一搜的PC端微信来了,赶紧来下载!
  2. Strusts2 高危漏洞又来了,老项目自查起来!
  3. 经典面试题:在这个场景下,你怎么进行性能调优?
  4. 一文聊透 Dubbo 优雅停机
  5. 大学计算机课算绩点吗,南京大学GPA是如何计算的
  6. html 里运行php文件,如何在HTML文件中运行PHP脚本
  7. css订单导航栏横线动画,小程序 纯css 实现tab导航栏下划线跟随动画
  8. python 节点_Python节点
  9. 【并发编程】线程中的Sleep、Yield、Join等api方法方法线程状态转换
  10. mxnet 衰减学习率