Jump to content

Czworan

New Members
  • Posts

    1
  • Joined

  • Last visited

Czworan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi. I'm working on some program. It adds new posts to facebook profiles, fanpages and groups. Everything works well, but when I want to create image uploading it just doesn't work (whitepage as result + file probably isn't even send, because of very short sending time). Multipart form sniffed with Firefox looks like this. I'm loading form to get all inputs and I'm using it as post_parameters for cURL. I'm replacing file1 with filename which is in same directory with PHP file. My $post_params looks like this. fb_dtsg=AQH8uaMrlc1w&charset_test=âŹ,´,âŹ,´,ć°´,Đ,Đ&file1=@C:\wamp\www\komek\haha.jpg&file2=&file3=&=Dodaj do albumu&return_uri=/groups/880573151971764?view=group&fc=photo_upload_success&return_uri_error=https://m.facebook.com/photos/upload/?target_id=880573151971764&target=880573151971764&ref=m_upload_pic&album_fbid=&csid=740af77e-8172-4b75-acae-39cd2e49782f&ctype=advanced&referrer=&is_old_composer=& And I'm posting it with cURL like this. //example generated $post_params $post_params = 'fb_dtsg=AQH8uaMrlc1w&charset_test=âŹ,´,âŹ,´,ć°´,Đ,Đ&file1=@C:\wamp\www\komek\haha.jpg&file2=&file3=&=Dodaj do albumu&return_uri=/groups/880573151971764?view=group&fc=photo_upload_success&return_uri_error=https://m.facebook.com/photos/upload/?target_id=880573151971764&target=880573151971764&ref=m_upload_pic&album_fbid=&csid=740af77e-8172-4b75-acae-39cd2e49782f&ctype=advanced&referrer=&is_old_composer=&'; $formAction = 'https://upload.facebook.com/_mupload_/composer/?waterfall_id=d6489f88fb22d5e6f96b3f8a2418020c $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0'); curl_setopt($ch, CURLOPT_URL, $formAction); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params); curl_setopt($ch, CURLINFO_HEADER_OUT, true); $response = curl_exec($ch); And I get whitepage + following info using CURL_INFO_HEADER_OUT POST /_mupload_/composer/?waterfall_id=d6489f88fb22d5e6f96b3f8a2418020c HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 Host: upload.facebook.com Accept: */* Cookie: mycookies Content-Length: 410 Content-Type: application/x-www-form-urlencoded Content-Length is a way to small (it should contains entire file). Uploading file takes ~20 seconds with Facebook. Request with cURL takes ~1 second, so it doesn't send my image. I was searching for solution, but everyone tells that to send file with multipart form I need add @ at begining of filepath, but
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.