Twitter PI更新个人资料横幅

时间:2012-11-10 17:54:00

标签: oauth twitter twitter-oauth

我无法使用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'];
}
?>

0 个答案:

没有答案