API Documentation

Feeling RESTful?

API v1 » uploadAndPost (POST w/ OAuth)

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 is used for uploading a photo to TwitPic and simultaneously posting content to Twitter. With this method, content that is posted will be saved to both TwitPic and Twitter, as opposed to the upload method that only saves the image on TwitPic.

This method will return a 401 Unauthorized if the user 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/1/uploadAndPost.format

Available Formats

xml, json

HTTP Method

POST

Requires Authentication

True

Parameters

  • key (Required): Your API Key.
  • consumer_token (Required): Your Twitter Consumer Token.
  • consumer_secret (Required): Your Twitter Consumer Secret.
  • oauth_token (Required): The Twitter OAuth Token for the user.
  • oauth_secret (Required): The Twitter OAuth Secret for the user.
  • message (Required): The tweet that belongs to the image.
  • 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 -F "consumer_token=GDdmIQH6jhtmLUypg82g" -F "consumer_secret=yOahq5m0YjDDjfjxHaXEsW9D+X0=" -F "oauth_token=819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw" -F "oauth_secret=yOahq5m0YjDDjfjxHaXEsW9D+X0=" -F "message=foo+bar" -F "key=098f6bcd4621d373cade4e832627b4f6" -F "media=@/path/to/image" http://api.twitpic.com/1/uploadAndPost.json