Write a tweet using “twitterOAuth” return an error

南笙酒味 提交于 2020-01-11 13:50:08

问题


I have this problem and are a lot of days that i'm tring to solve it.

I write a tweet using twitterOAuth

// OAuth To Twitter
require_once 'files-notifiche-twitter/twitteroauth.php';

// Do NOT Share (sono i token)
define("CONSUMER_KEY", "xxx");
define("CONSUMER_SECRET", "xxx");
define("OAUTH_TOKEN", "xxx");
define("OAUTH_SECRET", "xxx");

// Post To Twitter
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);
$content = $connection->get('account/verify_credentials');
$connection->post('statuses/update', array('status' => 'tweet'));


if ($connection->getLastHttpCode() != 200) {    //se non è riuscito a scrivere il tweet riprova
    print_r('<br>Error try again<br>');     
} 
else{
    print_r('<br>Notifica twitter funziona<br>');
}

print_r('OK');

This code works to write the tweet but then, in the last part, is how ther's an error...infact the print_r inside if statement is didn't write. The same for last print_r('OK')

Something break my code and i don't understand what....

Can you help me?

来源:https://stackoverflow.com/questions/51958555/write-a-tweet-using-twitteroauth-return-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!