Php 使用Twitter搜索API的位置和OAuth问题
我将确切地告诉大家我的家庭作业:在网站上添加twitter搜索功能。搜索应每20秒自动更新一次,并搜索最近提到的哈希标记“EN0700” tweet应该显示在一个列表中,其中包含日期、作者在twitter上的用户名以及tweet发布位置数据。我尝试使用示例中的,但它不显示位置结果。我的URL正确吗 另一件事是,如果我使用,我会收到:Php 使用Twitter搜索API的位置和OAuth问题,php,twitter,twitter-oauth,Php,Twitter,Twitter Oauth,我将确切地告诉大家我的家庭作业:在网站上添加twitter搜索功能。搜索应每20秒自动更新一次,并搜索最近提到的哈希标记“EN0700” tweet应该显示在一个列表中,其中包含日期、作者在twitter上的用户名以及tweet发布位置数据。我尝试使用示例中的,但它不显示位置结果。我的URL正确吗 另一件事是,如果我使用,我会收到: "{"error":"Could not authenticate you.","request":"/1/users/search.json?q=EN0745"}
"{"error":"Could not authenticate you.","request":"/1/users/search.json?q=EN0745"}"
虽然我已经在oAUTH注册了我的申请。谢谢您的帮助。您可以使用我的类来签署请求
您最好使用PHP库来实现这一点,以使事情变得简单。你可以找到他们
<?php
spl_autoload_register ( function ( $class ) {
require_once sprintf ( '%s.php' , $class ) ;
} ) ;
$URL = 'https://api.twitter.com/1/users/search.json';
$Data = Array ( 'q' => 'Search' ) ;
$Authentication = new \Twitter\TwitterAuthentication();
$Authentication->setConsumerKey ( 'UExmB6GoxftjZqdngw' );
$Authentication->setConsumerSecret ( '1yUvMAnrFiu86vCdhwAqM5ZHsgXRVyNhRdUDxeo' );
$Authentication->setAccessToken ( '2660353-PjccZS0nO28zaV0xaxR2UBklZR0nkjjso2wmLa' );
$Authentication->setAccessTokenSecret ( 'DWwLG3RFt1drU0qRc4PHu0wdlmVks08BDM' );
$OAuth = new Twitter\TwitterOAuthentication( $Authentication );
$OAuth->setSignatureURL ( $URL . '?' . http_build_query ( $Data , false , '&' ) ) ;
$OAuth->setSignatureMethod( 'GET' ) ;
$curl = curl_init();
curl_setopt( $curl , CURLOPT_URL , $URL . '?' . http_build_query ( $Data , false , '&' ) ) ;
curl_setopt( $curl , CURLOPT_HEADER , false ) ;
curl_setopt( $curl , CURLOPT_HTTPHEADER , Array ( $OAuth->buildAuthorization( $Data ) ) ) ;
curl_setopt( $curl , CURLOPT_RETURNTRANSFER , true ) ;
curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
$response = json_decode ( curl_exec ( $curl ) ) ;
print_r ( $response ) ;