facebookarchive / fbconsole

A micro api client for writing scripts against the Facebook Graph API.
Other
325 stars 74 forks source link

Uploading a photo produces HTTP Error 502 #17

Closed mertnuhoglu closed 12 years ago

mertnuhoglu commented 12 years ago

The following call produces an error:

>>> fb.post('/me/photos',{'source':open('0008.jpg')})

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
C:\java\python\Python27\Scripts\ in ()
----> 1 fb.post('/me/photos',{'source':open('0008.jpg')})

C:\java\python\Python27\lib\site-packages\fbconsole-0.3-py2.7.egg\fbconsole.pyc
in post(path, params)
    626
    627     """
--> 628     return _get_client().post(path, params=params)
    629
    630 def delete(path, params=None):

C:\java\python\Python27\lib\site-packages\fbconsole-0.3-py2.7.egg\fbconsole.pyc
in post(self, path, params)
    533             data, headers = poster.encode.multipart_encode(params)
    534             request = Request(self.__get_url(path), data, headers)
--> 535             return _safe_json_load(request)
    536         else:
    537             opener = build_opener(

C:\java\python\Python27\lib\site-packages\fbconsole-0.3-py2.7.egg\fbconsole.pyc
in _safe_json_load(*args, **kwargs)
    258
    259 def _safe_json_load(*args, **kwargs):
--> 260     f = _safe_url_load(*args, **kwargs)
    261     if six.PY3:
    262         return json.loads(f.read().decode('utf-8'))

C:\java\python\Python27\lib\site-packages\fbconsole-0.3-py2.7.egg\fbconsole.pyc
in _safe_url_load(*args, **kwargs)
    255     except HTTPError, e:
    256         error = _handle_http_error(e)
--> 257     raise error
    258
    259 def _safe_json_load(*args, **kwargs):

HTTPError: HTTP Error 502: Error parsing server response
mertnuhoglu commented 12 years ago

The following worked:

fb.post("/me/photos", {"message": "Great Photo", "source":open("0008.jpg"),'rb'})