我正在使用Twitterbot后端应用程序,我试图将可以保存然后阅读的字符串中的直接消息复制。如果我想成功地将它集成到我的AIML(人造智能标记语言)引擎中。PHP SimpleXML语法错误
当我运行该文件来测试它,我得到一个解析错误:
syntax error, unexpected T_VARIABLE referring to the line "file_put_contents('Program-O/InfoBot2012/test.xml', $direct_messages);"
我检查语法并没有明显的错误,因为我也跟着this线程。
$connection = new TwitterOAuth($consumer_key,$consumer_secret, $oAuthToken, $oAuthSecret);
$direct_messages = $connection->get('direct_messages');
$direct_messages = file_get_contents('https://api.twitter.com/1/direct_messages.json')
file_put_contents('Program-O/InfoBot2012/test.xml', $direct_messages);
$direct_messages = simplexml_load_file("test.xml");
file_put_contents不需要“$” – mseancole 2012-04-06 16:16:55
你好,我加了;和$的建议,但现在我得到更多的错误: “警告:file_get_contents()[function.file-get-contents]:无法找到包装”https“ - 你忘了启用它时,你配置PHP “和”警告:file_get_contents(https://api.twitter.com/1/direct_messages.json)[function.file-get-contents]:未能打开流:C:\ wamp \ www中的无效参数\ Program- O \ InfoBot2012 \ directmessage_test.php“引用$ direct_messages = file_get_contents('https://api.twitter.com/1/direct_messages.json'); – 2012-04-06 16:45:41
也出现这些错误: “Warning:file_put_contents(Program-O/InfoBot2012/test.xml)[function.file-put-contents]:无法打开流:C:\ wamp \ www中没有这样的文件或目录\ Program-O \ InfoBot2012 \ directmessage_test.php“引用file_put_contents行('Program-O/InfoBot2012/test.xml',$ direct_messages); 和“Warning:simplexml_load_file()[function.simplexml-load-file]:I/O警告:无法在C:\ wamp \ www \ Program-O \ InfoBot2012 \ directmessage_test中加载外部实体”test.xml“。 PHP“指的是代码行$ direct_messages = simplexml_load_file(”test.xml“); – 2012-04-06 16:46:11