0

从 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";
}                               

?>
4

1 回答 1

0

查找该 OAuth 库是否还支持,因为几个月前我尝试做同样的事情,我发现一些帖子告诉我从 3 月开始就不能再使用它了。无论如何,我不确定它是否是那个库,但如果你编写与 twitter 相关的代码,你必须知道他们经常更改他们的 API。

于 2013-06-27T18:59:16.650 回答