从亚伯拉罕twitteroauth的 - 无法验证你;错误:32 [英] TwitterOAuth from Abraham - Could not authenticate you; Error: 32
问题描述
我试图使用 TwitterOAuth对象从亚伯拉罕的解决方案。
I am trying to use the TwitterOAuth solution from Abraham.
我所做的一切,但我仍然得到这个错误:
I've done everything as described in his documentation, but I still get that error:
{错误:[{code:32,消息:无法验证你}]}
{"errors":[{"code":32,"message":"Could not authenticate you."}]}
这是我的源$ C $ C:
That's my source code:
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$consumerkey = 'xx';
$consumersecret = 'xx';
$accesstoken = 'xx';
$accesstokensecret = 'xx';
$connection = new TwitterOAuth($consumerkey,$consumersecret,$accesstoken,$accesstokensecret);
$tweets = $connection->get("search/tweets.json?q=superbowl");
echo json_encode($tweets);
所有按键是否正确。我不知道,为什么这仍然发生。
该应用程序的权限是只读的。
All the keys are correct. I have no clue, why this still happens. The App Permission are Read only.
我想要做的是基于搜索查询得到的鸣叫。
What I want to do is get tweets based on a search query.
你有任何想法如何解决这一问题?让我知道,如果你需要一些更多的信息。
Do you have any idea how to fix this? Let me know, if you need some more information.
推荐答案
希望这将解决您的问题....
Hope this will fix your problem....
<form action='' method='get' ><input type='text' name='q'> <button type='submit' >click</button></form>
<?php
require "autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$consumerKey = "youconsumerkey";
$consumerSecret = "yourconsumersecretkey";
$oauthToken = "youoauthtoken";
$oauthTokenSecret = "youroauthtokensecret";
$twitter = new TwitterOAuth($consumerKey,$consumerSecret,$oauthToken,$oauthTokenSecret);
$search = isset($_GET['q']);
if(isset($_GET['q'])){
$tweets = $twitter->get('search/tweets',array('q'=>'%23'.$_GET['q'],'result_type'=>'recent','count'=>'10'));
//var_dump($tweets);
foreach($tweets->statuses as $value){
echo $value->user->name; echo "<br/>";
//echo json_encode($tweets);
}
}
?>
#
其实在我的情况背后的原因]无法验证你;错误:32]
#
Actually in my case the reason behind ]Could not authenticate you; Error: 32]
是此行code的,我已经为我的项目进行测试:
was this line of code that i had tested for my project:
// $tweets = $twitter->get('search/tweets.json?q=mytest&result_type=recent&count=10');
我使用PHP TwitterOAuth对象库Twitter的REST API, https://twitteroauth.com/ 。
HTTP
GET https://api.twitter.com/1.1/search/tweets.json
TwitterOAuth对象
TwitterOAuth
$tweets= $twitter->get("search/tweets.json", array("result_type" => 'recent', "count" => 10)); //should be like this
// $tweets= $twitter->get('search/tweets.json?q=mi_twitter_test&result_type=recent&count=10'); //throws authentication error
这篇关于从亚伯拉罕twitteroauth的 - 无法验证你;错误:32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!