首页 > 解决方案 > 如何使用 TwitterOAuth PHP 编写推文?

问题描述

我想用我的应用程序 twitter 写一条推文,使用twitterOAuth. 我的代码可以编写推文,但是有一个错误(我不知道在哪里)破坏了我的代码。也许我使用的是旧版本的twitterOAuth

My code is this:

// 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) {    
    print_r('<br>Error try again<br>');     
} 
else{
   print_r('<br>Notifica twitter funziona<br>');
}

print_r('OK');

代码写推文但不在print_r内部if 语句和最后 **print_r('OK');

你能告诉我这段代码是否正确吗?我在哪里可以下载正确的版本twitterOAuth

在我的文件中twitterOAuth

 require_once('OAuth.php');

可能'OAuth.php'是老了……

非常感谢,对不起我的英语

标签: phptwitteroauthoauth-2.0twitter-oauth

解决方案


推荐阅读