Facebook Methods description: photos.upload

anna_150.jpg

Uploads a photo owned by the current session user and returns the new photo. See photo uploads for a description of the upload workflow. The only storable values returned from this call are pid, aid, and owner.

Parameters

 

string api_key The application key associated with the calling application.
string session_key The session key of the logged in user.
float call_id The request’s sequence number. Each successive call for any session must use a sequence number greater than the last. We suggest using the current time in milliseconds, such as PHP’s microtime(true) function.
string sig An MD5 hash of the current request and your secret key, as described in the authentication guide.
string v This must be set to 1.0 to use this version of the API.
string format Optional - desired response format. Either “XML” (default) or “JSON”.
string callback Optional - wrap the response inside a function call. This is primarily to enable cross-domain javascript requests using the <script> tag, sometimes known as “JSONP“. This works with both XML and JSON.
int aid Optional - The album id of the destination album.
string caption Optional - The caption of the photo.
data [no name] The raw image data for the photo.

If no album is specified, the photo will be uploaded to a default album for the application, which will be created if necessary. Regular albums have a size limit of 60 photos. Default application albums have a size limit of 1000 photos.Important: Upload requests must be formed as a MIME multipart message sent using POST data. Each argument, including the raw image data, should be specified as a separate chunk of form data.

The details of preparing a MIME multipart message depend on your particular request library, but typically the library will allow you to specify ‘POST’, set various MIME headers, then add additional data. The resulting MIME message should look like the following. Note that all line breaks in the message should be a carriage return followed by a newline (’\r\n’) rather than just a newline (’\n’). For example, after specifying each Content-Disposition line, you should print ‘\r\n\r\n’.

It is strongly recommended that you scale the image in your application before adding it to the request. The largest dimension should be at most 604 pixels (the largest display size Facebook supports).

Example Request

 

 

Content-Type: multipart/form-data; boundary=SoMeTeXtWeWiLlNeVeRsEe
MIME-version: 1.0

--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="method"

facebook.photos.upload
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="v"

1.0
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="api_key"

77a52842357422fadd912a2600e6e53c
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="session_key"

489727d0ab2efc6e8003018c-i2LLkn8BDb2s.
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="call_id"

1172623588.023010
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="caption"

Under the sunset
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="aid"

940915667462717
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; name="sig"

dfa724b8a5cd97d9df4baf2b60d3484c
--SoMeTeXtWeWiLlNeVeRsEe
Content-Disposition: form-data; filename="somefilename.jpg"
Content-Type: image/jpg

[Raw file data here]
--SoMeTeXtWeWiLlNeVeRsEe--

Example Return XML

 

 

<?xml version="1.0" encoding="UTF-8"?>
<photos_upload_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
  <pid>940915697041656</pid>
  <aid>940915667462717</aid>
  <owner>219074</owner>
  <src>http://ip002.facebook.com/v67/161/72/219074/s219074_31637752_5455.jpg</src>
  <src_big>http://ip002.facebook.com/v67/161/72/219074/n219074_31637752_5455.jpg</src_big>
  <src_small>http://ip002.facebook.com/v67/161/72/219074/t219074_31637752_5455.jpg</src_small>
  <link>http://www.facebook.com/photo.php?pid=31637752&id=219074</link>
  <caption>Under the sunset</caption>
</photos_upload_response>

Error codes

1 An unknown error occurred. Please resubmit the request.
2 The service is not available at this time.
5 The request came from a remote address not allowed by this application.
100 One of the parameters specified was missing or invalid.
101 The api key submitted is not associated with any known application.
102 The session key was improperly submitted or has reached its timeout. Direct the user to log in again to obtain another key.
103 The submitted call_id was not greater than the previous call_id for this session.
104 Incorrect signature.
120 Invalid album id.
321 Album is full.
324 Missing or invalid image file.
325 Too many unapproved photos pending.

Source page

Tags: ,

Related Post

No Comments

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a comment