0

I am working on Twitterbot backend application and I am trying to copy the direct messages in strings that can be saved and then read. If I want to successfully integrate that into my AIML (artifical intelligence markup language) engine.

As I run the file to test it, I get a Parse error:

syntax error, unexpected T_VARIABLE referring to the line "file_put_contents('Program-O/InfoBot2012/test.xml', $direct_messages);" 

I checked the syntax and there is no apparent error since I followed this thread.

$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");

3 Answers 3

1
$direct_messages = file_get_contents('https://api.twitter.com/1/direct_messages.json')
                                                                                      ^--

You're missing a ; at the point I've marked.

Sign up to request clarification or add additional context in comments.

3 Comments

file_put_contents requires no "$"
hello, i added the ; and the $ as suggested but now i get even more errors: "Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP" and "Warning: file_get_contents(api.twitter.com/1/direct_messages.json) [function.file-get-contents]: failed to open stream: Invalid argument in C:\wamp\www\Program-O\InfoBot2012\directmessage_test.php" referring to the line $direct_messages = file_get_contents('api.twitter.com/1/direct_messages.json');
also these other errors: "Warning: file_put_contents(Program-O/InfoBot2012/test.xml) [function.file-put-contents]: failed to open stream: No such file or directory in C:\wamp\www\Program-O\InfoBot2012\directmessage_test.php" referring to the line file_put_contents('Program-O/InfoBot2012/test.xml', $direct_messages); and "Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "test.xml" in C:\wamp\www\Program-O\InfoBot2012\directmessage_test.php" referring to the line of code $direct_messages = simplexml_load_file("test.xml");
1

You have to enable php_openssl.dll (dll since you're using windows).

You can do this by opening up php.ini (usually apache/bin/php.ini in your xampp / EasyPHP folder), and remove the ";" before the line "extension=php_openssl.dll" (so you uncomment it), or add 'extension=php_openssl.dll' to the bottom of your file.

This way php_openssl.dll will be loaded, and PHP will know how to handle HTTPS.

Comments

0

According to the Twitter documentation on direct_messages api, the request https://api.twitter.com/1/direct_messages.json will return a JSON response, which you are trying to save and load as XML.

Try https://api.twitter.com/1/direct_messages.xml instead.

Hope it helps.

1 Comment

thanks for ur reply but it doesn't work either by trying with api.twitter.com/1/direct_messages.xml...I am getting same errors as previously posted...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.