Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.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
无法使用PHP获取扩展Tweet_Php_Twitter_Php Curl - Fatal编程技术网

无法使用PHP获取扩展Tweet

无法使用PHP获取扩展Tweet,php,twitter,php-curl,Php,Twitter,Php Curl,我有一个已经运行的Twitter应用程序,我正在使用它在我的网站上使用PHP CURL显示时间线。现在我想使用tweet\u mode=extended来获取280个字符,但它说明了身份验证问题 以下是我的代码: $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $oauth_access_token = "XXXXX"; $oauth_access_token_secret = "XXXXX"; $consum

我有一个已经运行的Twitter应用程序,我正在使用它在我的网站上使用PHP CURL显示时间线。现在我想使用
tweet\u mode=extended
来获取280个字符,但它说明了身份验证问题

以下是我的代码:

$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";

$oauth_access_token = "XXXXX";
$oauth_access_token_secret = "XXXXX";
$consumer_key = "XXXXX";
$consumer_secret = "XXXXX";

$oauth = array(
            'screen_name' => 'MAhmadZ',
            'count' => 4,
            'oauth_consumer_key' => $consumer_key,
            'oauth_nonce' => time(),
            'oauth_signature_method' => 'HMAC-SHA1',
            'oauth_token' => $oauth_access_token,
            'oauth_timestamp' => time(),
            'oauth_version' => '1.0'
        );

//build the base string
$temp = array();
ksort($oauth);
foreach($oauth as $key => $value):
    $temp[] = "$key=" . rawurlencode($value);
endforeach;
$base_info = 'GET&' . rawurlencode($url) . '&' . rawurlencode(implode('&', $temp));
unset( $temp );

$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, TRUE));
$oauth['oauth_signature'] = $oauth_signature;

//build authorization header for making request
$temp = 'Authorization: OAuth ';
$values = array();
foreach($oauth as $key=>$value):
    $values[] = "$key=\"" . rawurlencode($value) . "\"";
endforeach;

$temp .= implode(', ', $values);
$header = array($temp, 'Expect:');
unset( $temp );

$options = array(
            CURLOPT_HTTPHEADER => $header,
            CURLOPT_HEADER => FALSE,
            CURLOPT_URL => $url . '?screen_name=MAhmadZ&count=4',
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_SSL_VERIFYPEER => FALSE
        );

$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);

$twitter_data = json_decode($json);

使用“tweet_mode=extended”获取扩展/完整tweet 请点击此处了解更多详细信息:

我想这是卷曲的问题。使用此库可避免错误: