从 php 发布推文后,我无法获得任何结果。我已经在 twitter 上注册了我的应用程序并获得了我的凭据。我创建了一个名为 access_tokens.php 的页面,并下载了一个名为 tmhOAuth.php 的 OAuth 库。我正在完全按照示例教程进行操作,但似乎没有出现任何内容-可以提供任何帮助吗?
access_tokens.php
<?php
$consumer_key = 'xx';
$consumer_secret = 'xx';
$user_token = 'xx';
$user_secret = 'xx';
//xx is the replacement for my actual values
?>
post_tweet.php
<?php
//Load the app's keys into memory
require 'app_tokens.php';
//Load the tmOAuth library
require 'tmhOAuth.php';
//Create an OAuth connection to the Twitter API
$connection = new tmhOAut(array(
'consumer_key' => $consumer_key,
'consumer_secret'=> $consumer_secret,
'user_token' => $user_token,
'user_secret' => $user_secret
));
//Send a tweet
$code = $connection -> request('POST',
$connection -> url('1.1/statuses/update'),
array('status' => 'Hello Twitter'));
//A response code of 200 is a success
if ($code == 200){
print "Tweet sent";
}
else{
print "Error:$code";
}
?>