Description
This API endpoint is used for both photos and videos. If you are developing an app that already has TwitPic image upload support, nothing with the API endpoint has changed for video.
This method will return a 401 Unauthorized if the OAuth header was not present or could not be verified with Twitter. It will return a 400 Bad Request if one of the required parameters is missing.
Please note that any message posted as a photo caption will be publicly visible.
URL
http://api.twitpic.com/2/upload.format
Available Formats
xml, json
HTTP Method
POST
Requires Authentication
True
Headers
X-Verify-Credentials-Authorization (Required)
Header Example
OAuth realm="http://api.twitter.com/", oauth_consumer_key="GDdmIQH6jhtmLUypg82g", oauth_signature_method="HMAC-SHA1", oauth_token="819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw", oauth_timestamp="1272325550", oauth_nonce="oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y", oauth_version="1.0", oauth_signature="U1obTfE7Rs9J1kafTGwufLJdspo%3D"
X-Auth-Service-Provider (Required)
https://api.twitter.com/1/account/verify_credentials.json
Parameters
- key (Required): Your API Key.
- message (Required): The tweet that belongs to the image. Can be empty string.
- media (Required): The file upload data.
Responses
If you receive a HTTP 200 OK header, you can assume the image was successfully uploaded.
Sample XML Response
<?xml version="1.0" encoding="UTF-8"?> <image> <id>1lacuz</id> <text>test</text> <url>http://twitpic.com/1lacuz</url> <width>220</width> <height>84</height> <size>8722</size> <type>png</type> <timestamp>Wed, 05 May 2010 16:11:15 +0000</timestamp> <user> <id>12345</id> <screen_name>twitpicuser</screen_name> </user> </image>
Sample JSON Response
{
"id" : "1lad07",
"text" : "test",
"url" : "http:\/\/twitpic.com\/1lacuz",
"width" : 220,
"height" : 84,
"size" : 8722,
"type" : "png",
"timestamp" : "Wed, 05 May 2010 16:11:48 +0000",
"user" : {
"id" : 12345,
"screen_name" : "twitpicuser"
}
}
Example CURL Command
curl -v -H 'X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json' -H 'X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/", oauth_consumer_key="GDdmIQH6jhtmLUypg82g", oauth_signature_method="HMAC-SHA1", oauth_token="819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw", oauth_timestamp="1272325550", oauth_nonce="oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y", oauth_version="1.0", oauth_signature="U1obTfE7Rs9J1kafTGwufLJdspo%3D"' -F "key=098f6bcd4621d373cade4e832627b4f6" -F "media=@/path/to/image" http://api.twitpic.com/2/upload.json