我使用PHP创建了我的Twitter应用程序,但我不知道如何在Twitter API中添加参数,我的代码:
$twitter_url = 'https://api.twitter.com/1.1/users/show.json'; // do not change it!
$data = array('oauth_consumer_key' => $consumer_key,
'oauth_nonce' => time(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => time(),
'oauth_token' => '492687736-xxxxxxxx',
'oauth_version' => '1.0');
$baseString = buildBaseString($twitter_url, $data);
$compositeKey = $consumer_secret."&xxxxxxxx";
oauth_signature = base64_encode(hash_hmac('sha1', $baseString, $compositeKey, true));
$data['oauth_signature'] = $oauth_signature;
$response = sendRequest($data, $twitter_url);
$json = json_decode($response, true);
print_r($json);
我的代码与" status / user_timeline" (没有参数)我得到了我的时间表,但是当使用" users / show" (没有参数)我收到了这条消息:
Array ( [errors] => Array ( [0] => Array ( [code] => 50 [message] => User not found. ) ) )
当使用这样的参数时:
$twitter_url = 'https://api.twitter.com/1.1/users/show.json?screen_name=jack';
我收到了这条消息:
Array ( [errors] => Array ( [0] => Array ( [code] => 32 [message] => Could not authenticate you. ) ) )
现在我想知道如何在我的代码中添加参数?
我不想要任何Twitter PHP库。