我无法使用 tmhoauth 更改横幅图像。每次我发布图像时,无论是本地托管还是来自 URL,我都会得到返回码 422 - 这表明图像文件的大小太大或尺寸不正确。无论图像大小或尺寸如何,都会发生这种情况。有任何想法吗?这是代码 - 我已经删除了令牌
<?php
$banner_image = 'image1.jpg';
$result = post_tweet($banner_image);
print "Response code: " . $result . "\n";
function post_tweet($banner_image) {
require_once('tmhOAuth.php');
print "Posting...\n";
$connection = new tmhOAuth(array(
'consumer_key' => '---',
'consumer_secret' => '---',
'user_token' => '---',
'user_secret' => '---',
'curl_ssl_verifypeer' => false
));
$connection->request('POST', $connection->url('1/account/update_profile_banner'), array('banner'=>$banner_image), true, true);
return $connection->response['code'];
}
?>
已解决:谢谢@bdares!对于犯此愚蠢错误或需要 update_profile_banner 代码帮助的其他人,如下所示:
$banner_image = 'image1.jpg';
$result = post_tweet($banner_image);
print "Response code: " . $result . "\n";
function post_tweet($banner_image) {
require_once('tmhOAuth.php');
print "Posting...\n";
$connection = new tmhOAuth(array(
'consumer_key' => '---',
'consumer_secret' => '---',
'user_token' => '---',
'user_secret' => '---',
'curl_ssl_verifypeer' => false
));
$connection->request('POST', $connection->url('1/account/update_profile_banner'), array('banner'=>'banner'=>"@{$banner_image};type=image/jpeg;filename={$banner_image}"), true, true);
return $connection->response['code'];
}
?>