TweetPress API

Here is the API for interfacing with TweetPress.  Note: Make all requests to the homepage of the user’s blog.  Also, be sure to include the /index.php if the user doesn’t.  This is to ensure that you will POST to the correct location.

For example.  If the user’s blog address is http://stone.com/gallery , make sure you POST to http://stone.com/gallery/index.php .

API Methods

Ping

This method is used to determine if the user has TweetPress installed on their blog.  You simply make a GET request to their blog address with the following parameters

  • tp_ping – just set to true (it can actually be any value, 1 would suffice as well)
  • username – The user’s wordpress username
  • password -  The user’s wordpress password

If the user does not require authentication to post images, username and password can be omitted.  If you leave them, they will just be ignored.

Sample Request

http://brandontreb.com/index.php?tp_ping=true&username=foo&password=bar

Sample Response

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<rsp stat=”ok”>
<message>TweetPress plugin successfully installed</message>
</rsp>

Upload

This is a POST request to the user’s blog homepage (including the index.php). Example http://brandontreb.com/index.php .  (post data should be formatted as multipart/form-data) The following fields should be included in your POST.

  • media – Binary image data
  • username – The user’s WordPress username. required if the user requires WordPress authentication to POST
  • password – The user’s WordPress password. required if the user requires WordPress authentication to POST
  • message [Optional] – The Tweet associated with this photo
  • latitude [Optional] -  The latitude of the user posting the photo
  • longitude [Optional] – The longitude of the user posting the photo

Sample Response

<?xml version=”1.0″ encoding=”UTF-8″?>
<rsp stat=”ok”>
<mediaid>34</mediaid>
<mediaurl>http://b1t.me/21</mediaurl>
<imageurl>http://brandontreb.com//wp-content/tweetpress/ivMlo.jpg</imageurl>
<thumburl>http://brandontreb.com//wp-content/tweetpress/thumbnails/ivMlo.jpg</thumburl>
</rsp>

Note, thumbnails are only created if their version of WordPress supports it.

Errors

  1. Ping Error – There are 2 error states.  The first occurs when the user doesn’t even have TweetPress installed.  In this case, you will get back HTML (of the user’s homepage) rather than valid XML.  If this occurs, point the user to http://brandontreb.com/tweetpress and instruct them to install the TweetPress plugin.
    The second error state occurs when the username or password are incorrect for the WordPress site.  This only happens if the user requires validation when posting images
  2. Upload Error – There are 4 errors that can occur during this process. 1 invalid username or password. 2 no image data provided. 3 invalid image type. 4 error writing to disk

Sample Error Response

<?xml version=”1.0″ encoding=”UTF-8″?>
<rsp stat=”fail”>
<err code=”1″ msg=”Invalid username or password” />
</rsp>