1
我正在使用tmhOauth库将状态发布到twitter。tmhOauth update_with_media使用hashtag禁止
为什么我得到403
当我尝试update_with_media与它内的hashtag。下面是完整的代码。
session_start();
require 'tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'MYKEY',
'consumer_secret' => 'MYSECRET',
'curl_ssl_verifypeer' => false
));
if(isset($_GET['oauth_verifier'])){
$tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
$tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
$code = $tmhOAuth->request(
'POST',
$tmhOAuth->url('oauth/access_token', ''),
array(
'oauth_verifier' => $_GET['oauth_verifier']
)
);
if($code == 200){
$_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
$tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
$tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
$base64_data = file_get_contents($_SESSION['twitter_image_data']);
$status = <<<EOD
You can see yourself at Catholic U, too! Go to somelink.com to check out this cool app!
#hashtag
EOD;
echo strlen($status);
$params = array(
'media[]' => "{$base64_data};type=image/jpeg;filename=myimage.jpg",
'status' => $status
);
$response = $tmhOAuth->user_request(array(
'method' => 'POST',
'url' => $tmhOAuth->url("1.1/statuses/update_with_media"),
'params' => $params,
'multipart' => true
));
print_r($response);
if($response == 200){
?>
<pre>Your image has been uploaded to twitter. this window will be closed in 3 seconds...</pre>
<script>
setTimeout(function(){
window.close();
}, 3000);
</script>
<?php
}
unset($_SESSION['oauth']);
unset($_SESSION['twitter_image_data']);
}
}
反正要调试吗? $response
只返回响应号码。请帮助
它似乎叽叽喳喳update_with_media只允许108个字符的状态,我试图截断一些文本状态,它运作良好。 – 2014-11-22 00:03:16
它是有道理的,一些网站也包括禁止(限制)数据的403错误。找出发生了什么的一个好方法是使用Internet Explorer访问403错误,因为ie显示错误的扩展名,例如:403.14。您可以在这里看到所有错误和扩展的列表:http://support.microsoft.com/kb/943891 – Verhaeren 2014-11-22 02:09:34