我试图通过j7mbo的包装器使用Twitter API更新用户个人资料,但我收到了以下回复...
{"请求":" /1.1/account/update_profile_image.json","错误":"不 公认"}
正在使用的代码是......
return NSArray(array: self).count
答案 0 :(得分:0)
只需发布原始base-64编码图像;没有标题。 Twitter处理它们的结果。 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAA...
执行此操作的简便方法是base64_encode(file_get_contents("./images/tw_image.png")))
答案 1 :(得分:0)
您需要将文件转换为base64_encode。
function getImageProfile() {
$path = 'yourimage.jpg'; //path of image file
$file = file_get_contents($path);
$data = base64_encode($file);
return $data;
}
使用API https://api.twitter.com/1.1/account/update_profile_image.json
通过POST发送参数$postfields = array('image' => $this->getImageProfile(),
'include_entities' => false,
'skip_status' => false);
$twitter = new TwitterAPIExchange($settings);
echo $twitter->buildOauth($url_api_update_profile_image, $method)
->setPostfields($postfields)
->performRequest();