Twitter и загрузка аватора

Статус
В этой теме нельзя размещать новые ответы.

D@nil

Постоялец
Регистрация
1 Окт 2006
Сообщения
340
Реакции
122
Здравствуйте

подскажите в чем может быть проблема
PHP:
$reg = post('http://twitter.com/settings/profile');

preg_match('#<input name="authenticity_token" type="hidden" value="(.*?)"#i',$reg,$form_auth);

$reg = post('http://twitter.com/settings/profile',array(
'_method'=>'put',
'authenticity_token'=>trim($form_auth[1]),
'profile_image[uploaded_data]'=>"@./img.jpg",
'user[name]'=>"Nick",
'user[location]'=>"",
'user[url]'=>"http://",
'user[description]'=>"infa obomne",
'commit'=>"Save"),'http://twitter.com/settings/profile');

function post($url,$post=0,$refer=FALSE)    {
       $ch = curl_init($url);
              
       if($post) {
           curl_setopt($ch, CURLOPT_POST, 1);
           curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
       }
       
       curl_setopt($ch, CURLOPT_COOKIEJAR, "./tmp/cook");
       curl_setopt($ch, CURLOPT_COOKIEFILE, "./tmp/cook");
       
       curl_setopt($ch, CURLOPT_HEADER, 1);
       
       //curl_setopt($ch, CURLOPT_VERBOSE, 1);
       
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
       curl_setopt($ch, CURLOPT_TIMEOUT, 30);  
       
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       

       $result  = curl_exec($ch);
       
       return $result;
}

Выдает ошибку: HTTP/1.1 417 Expectation Failed

Требуемый запрос:
Код:
POST /settings/profile HTTP/1.1
Host: twitter.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Referer: http://twitter.com/settings/profile
Cookie: __utma=43838368.370652090.1262718750.1265176980.1265212108.9; __utmz=43838368.1265212108.9.4.utmcsr=google.ru|utmccn=(referral)|utmcmd=referral|utmcct=/reader/view/; __utmv=43838368.lang%3A%20en; auth_token=1266677532%7C30606cea521a1117c78bbd3151770b0b668072b7; _twitter_sess=BAh7FjoVaW5fbmV3X3VzZXJfZmxvdzA6E3Bhc3N3b3JkX3Rva2VuIi1hZTRk%250AYTBmMTUwN2ZkYmU3MGUyOTI0OTgxMTZhOThlMDczMzIzMTRiOhF0cmFuc19w%250Acm9tcHQwOg5yZXR1cm5fdG8iKGh0dHA6Ly90d2l0dGVyLmNvbS9zZXR0aW5n%250Acy9hY2NvdW50IipzaG93X2Rpc2NvdmVyYWJpbGl0eV9mb3JfbWFuZnJlZDRm%250Ab2t1MDoNYWRtaW5faWQwIilzaG93X2Rpc2NvdmVyYWJpbGl0eV9mb3JfZGFl%250AZGVueHpva3UwIiVzaG93X2Rpc2NvdmVyYWJpbGl0eV9mb3JfcmF3aWVpbTA6%250AF2NvbnRyaWJ1dGluZ190b19pZDAiKHNob3dfZGlzY292ZXJhYmlsaXR5X2Zv%250Acl9qZWFuZWs5b2t1MCIpc2hvd19kaXNjb3ZlcmFiaWxpdHlfZm9yX2NyaXNz%250AeXc1b2t1MDoJdXNlcmkE6yPpBjoMY3NyZl9pZCIlYTg3Y2U2ZjkxNTI3MDAw%250AODFjOTg1OWU1N2U4MmQwOWQiKHNob3dfZGlzY292ZXJhYmlsaXR5X2Zvcl9p%250AbmRyYXZwb2t1MDoHaWQiJTIwM2VhZjliM2IwM2RlMzQ2MTk0YTUxYmI4MDlk%250AOGI5IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI%250AYXNoewAGOgpAdXNlZHsAIipzaG93X2Rpc2NvdmVyYWJpbGl0eV9mb3JfZG9t%250AaW5nb2Vob2t1MA%253D%253D--b5c11f52b633ac25557a614f92e4f36a0bd2f987; lang=en
Content-Type: multipart/form-data; boundary=---------------------------24429324046705
Content-Length: 7755

-----------------------------24429324046705
Content-Disposition: form-data; name="_method"

put
-----------------------------24429324046705
Content-Disposition: form-data; name="authenticity_token"

55afcf5e471772801553560f486393914fd6925e
-----------------------------24429324046705
Content-Disposition: form-data; name="profile_image[uploaded_data]"; filename="img.jpg"
Content-Type: image/jpeg

***img content***
-----------------------------24429324046705
Content-Disposition: form-data; name="user[name]"

Rawie
-----------------------------24429324046705
Content-Disposition: form-data; name="user[location]"


-----------------------------24429324046705
Content-Disposition: form-data; name="user[url]"

http://
-----------------------------24429324046705
Content-Disposition: form-data; name="user[description]"

8888787
-----------------------------24429324046705
Content-Disposition: form-data; name="commit"

Save
-----------------------------24429324046705--
 
PHP:
'profile_image[uploaded_data]'=>"@./img.jpg",
//на
'profile_image[uploaded_data]'=>"@".dirname(__file__)."img.jpg",
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху