Problems uploading pictures to Facebook wall.

Posted by Miguel Ángel Ortuño on Stack Overflow See other posts from Stack Overflow or by Miguel Ángel Ortuño
Published on 2010-05-18T10:55:06Z Indexed on 2010/05/18 11:00 UTC
Read the original article Hit count: 324

Filed under:
|
|

Hi, i'm trying to upload a JPEG picture to Facebook wall using libcurl. Appareantly the connection is established but cURL hangs when waiting for server response.

The libcurl output is the following:

  • About to connect() to api.facebook.com port 80 (#0)
  • Trying 66.220.146.15... * connected
  • Connected to api.facebook.com (66.220.146.15) port 80 (#0)

POST /restserver.php?api_key=e57addd5a98ac4445e36359043ded182&call_id=3&caption=ddfg&format=JSON&method=facebook.photos.upload&session_key=a3fc731e4c0329201606daeb-723233322&sig=a3f32226cff3e49ec799cf7dcc17a57e&ss=1&v=1.0?method=photos.upload HTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 Host: api.facebook.com Accept: / Content-Type: multipart/form-data; charset=UTF-8; boundary=PPoSt_dElImTTer MIME-version: 1.0

Content-Length: 128033 Expect: 100-continue

  • Done waiting for 100-continue

And the C++ code is as follow:

String post_header = "Content-Type: multipart/form-data; charset=UTF-8; boundary=PPoSt_dElImTTer\r\nMIME-version: 1.0\r\n";

        // POST binary data
        curl_slist* chunk = NULL; 
        chunk = curl_slist_append(chunk, post_header.c_str()); 

        curl_easy_setopt(m_http, CURLOPT_HTTPHEADER, chunk); 

        curl_easy_setopt(m_http, CURLOPT_POST, true);
        curl_easy_setopt(m_http, CURLOPT_POSTFIELDS, buf);
        curl_easy_setopt(m_http, CURLOPT_POSTFIELDSIZE, all_size);

        curl_easy_setopt(m_http, CURLOPT_URL, m_request.c_str());
        curl_easy_setopt(m_http, CURLOPT_WRITEFUNCTION, Facebook::Request::httpCallback); 
        curl_easy_setopt(m_http, CURLOPT_WRITEDATA, this);
        curl_easy_setopt(m_http, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
        curl_easy_setopt(m_http, CURLOPT_VERBOSE, true);

© Stack Overflow or respective owner

Related posts about libcurl

Related posts about c++