我正在使用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