Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter API OAuth PHP post_tweet.PHP_Php_Api_Twitter_Oauth - Fatal编程技术网

Twitter API OAuth PHP post_tweet.PHP

Twitter API OAuth PHP post_tweet.PHP,php,api,twitter,oauth,Php,Api,Twitter,Oauth,我无法从php发布tweet后获得任何结果。我已经在twitter上注册了我的应用程序,并获得了我的证书。我制作了一个名为access_tokens.php的页面,并下载了一个名为tmhOAuth.php的OAuth库。我正遵循一个示例教程,但似乎什么也没有出现-有什么可以提供的帮助吗 访问\u tokens.php <?php $consumer_key = 'xx'; $consumer_secret = 'xx'; $user_token = 'xx'; $user_secret

我无法从php发布tweet后获得任何结果。我已经在twitter上注册了我的应用程序,并获得了我的证书。我制作了一个名为access_tokens.php的页面,并下载了一个名为tmhOAuth.php的OAuth库。我正遵循一个示例教程,但似乎什么也没有出现-有什么可以提供的帮助吗

访问\u 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";
}                               

?>

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

IDK,如果OAuth库得到支持,但我确实让它与另一个库一起工作。现在如果我能让时间线显示出来而不是空白就好了。太棒了!