我通过Twitter的API更新背景有点麻烦。通过API更新Twitter背景
$target_url = "http://www.google.com/logos/11th_birthday.gif";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html = curl_exec($ch);
$content = $to->OAuthRequest('http://twitter.com/account/update_profile_background_image.xml', array('profile_background_image_url' => $html), 'POST');
当我尝试通过卷曲或的file_get_contents拉的原始数据,我得到这个...
预期失败的预期要求头 场给出的期望不能通过这台服务器遇见。 客户发送 期望:100-继续,但我们只允许100-继续期望。
您的原始代码实际上是正确的,期待它指出URL_HERE需要成为实际数据的'profile_background_image'=>'URL_HERE'。因此,甚至在发出OAUTH请求之前,您需要使用PHP cURL从图像URL中刮取图像数据,并将其放置在profile_background_image选项中。 – jakeisonline 2009-09-27 09:36:32
你有没有使用PHP cURL的经验?如果不是这样,我当然可以指出你的方向是正确的,但是会有轻微的学习曲线。我很害怕 – jakeisonline 2009-09-27 10:15:10
我现在正在测试这个,会看看实际正在传递的内容,并让你知道。 – jakeisonline 2009-09-27 10:51:02