A few users have been pressing me to make this, so I started this morning throwing something together.
I haven't really made a documentation on it yet.. but if it starts being used, I'll make one. This should suffice for now.
---------------------------
If you have any questions, please e-mail me at: [email protected]
---------------------------
For right now I only have five methods:
- check.credentials
- get.Images
- album.getInfo
- upload.Image
- user.Info
To use these methods you must provide the user's username and password.
Each method returns an XML feed with information (starting with <tehupload> ending with </tehupload>)
---------------------------------------
check.credentials
---------------------------------------Parameters:Here is an example URL, with an example response:
username - TehUpload username
password - TehUpload password
Returns:
status - error, success
message - message relating to status
Code:http://www.tehupload.com/api/check.credentials/username=username&password=passwordA successful response will return:Code:<tehupload> <status>error</status> <message>credentials are incorrect</message> </tehupload>
PHP Example:Code:<tehupload> <status>success</status> <message>credentials are correct</message> </tehupload>
---------------------------------------PHP Code:<?php
$username = "Bob";
$password = "Jimbo";
$file = @file_get_contents( "http://www.tehupload.com/api/check.credentials/username={$username}&password={$password}" );
$xml = new SimpleXMLElement( $file );
if($xml->status == "error") {
echo "Wrong Credentials";
} else {
echo "Good Credentials";
}
?>
get.Images
---------------------------------------Parameters:Here is an example URL, with an example response:
username - TehUpload username
password - TehUpload password
count - how many images are returned (default - 20)
Returns:
status - error, success
message - message relating to status
count - how many images are returned
username - TehUpload username
userid - TehUpload userID
imagesinfofilename - Image Filenamealbum
filetype - Image mime type
filesize - File size, in bytes
timestamp - Timestamp uploadeddisplay - is private album? 1 = no, 0 = yeslinks
albumID - ID of the album image is in (album.getInfo)full - link to full sized image
thumbssmall - link to small thumb
medium - link to medium thumb
large - link to large thumb
Code:http://www.tehupload.com/api/get.Images/username=username&password=password&count=1PHP Example:Code:<tehupload> <status>success</status> <message>credentials are correct</message> <content> <count>1</count> <username>barrymingle</username> <userid>95</userid> <images> <images> <info> <filename>9622bfe3471e8d1IMG_3250__Medium_.JPG</filename> <filetype>image/jpeg</filetype> <filesize>110120</filesize> <timestamp>1224944856</timestamp> </info> <album> <display>1</display> <albumID>339</albumID> </album> <links> <full>http://www.tehupload.com/uploads/9622bfe3471e8d1IMG_3250__Medium_.JPG</full> <thumbs> <small>http://www.tehupload.com/thumbs/9622bfe3471e8d1IMG_3250__Medium_.JPG</small> <medium>http://www.tehupload.com/thumbs/m/9622bfe3471e8d1IMG_3250__Medium_.JPG</medium> <large>http://www.tehupload.com/thumbs/l/9622bfe3471e8d1IMG_3250__Medium_.JPG</large> </thumbs> </links> </images> </images> </content> </tehupload>
---------------------------------------PHP Code:<?php
$username = "Bob";
$password = "Jimbo";
$file = @file_get_contents( "http://www.tehupload.com/api/get.Images/username={$username}&password={$password}&count=1" );
$xml = new SimpleXMLElement( $file );
$filename = $xml->content->images->image[0]->filename;
?>
album.getInfo
---------------------------------------Parameters:Here is an example URL, with an example response:
username - TehUpload username
password - TehUpload password
albumID - ID of the album you wish to get information about
count - number of items you want returned
Returns:
status - error, success
message - message relating to status
albumowner - owner userIDimages
"owner-username" - owner username
title - album title
"default-image" - default image filename
private - is album private? 0 = no, 1 = yes
info
filename - image filenamealbum
filetype - mime filetype
filesize - filesize in bytes
timestamp - unix timestamp when uploadeddisplay - should it be shown on main page? private = 0links
albumID - album that image is infull - link to full sized imagethumbssmall - link to small thumb
medium - link to medium thumb
large - link to large thumb
Code:http://www.tehupload.com/api/album.getInfo/username=username&password=pass&albumID=165PHP Example:Code:<tehupload> <status>success</status> <message>credentials are correct</message> <content> <album> <owner>12</owner> <owner-username>Source</owner-username> <title>App</title> <default-image></default-image> <created-timestamp>1219104048</created-timestamp> <private>0</private> </album> <images> <images> <info> <filename>app-625430429160603934.png</filename> <filetype>image/png</filetype> <filesize>33693</filesize> <timestamp>1219185077</timestamp> </info> <album> <display>1</display> <albumID>165</albumID> </album> <links> <full>http://www.tehupload.com/uploads/app-625430429160603934.png</full> <thumbs> <small>http://www.tehupload.com/thumbs/app-625430429160603934.png</small> <medium>http://www.tehupload.com/thumbs/m/app-625430429160603934.png</medium> <large>http://www.tehupload.com/thumbs/l/app-625430429160603934.png</large> </thumbs> </links> </images> </images> </content> </tehupload>
---------------------------------------PHP Code:<?php
$username = "Bob";
$password = "Jimbo";
$file = @file_get_contents( "http://www.tehupload.com/api/album.getInfo/username={$username}&password={$password}&albumID=15&count=1" );
$xml = new SimpleXMLElement( $file );
$albumTitle = $xml->content->album->title;
?>
upload.Image
---------------------------------------Parameters:Here is an example URL, with an example response:
username - TehUpload username - OPTIONAL
password - TehUpload password - OPTIONAL
album - ID of the album you wish to upload to - OPTIONAL
imageData - actual file data of image you wish to upload
Returns:
status - error, success
message - message relating to status
information
filename - filename of image (appended with api-)links
id - ID of image
filetype - mime filetype
filesize - filesize in bytes
album - if user, pass, album specified; returns albumID of file
user - if user, pass, album specified; returns userID of file
"uploaded-timestamp" - unix timestamp when uploaded (can be used to sort relative time)thumbssmall - link to small thumbnailfullSize - link to fullSize image
medium - link to medium thumbnail
large - link to large thumbnail
share - link to share page (http://www.tehupload.com/share/id)
"album-share" (if usernam & password & album specified, returns share link to album)
Code:http://www.tehupload.com/api/upload.Image/username=username&password=pass&album=165PHP Example:Code:<tehupload> <content> <information> <filename>api-958768cb2cdf79e900528cb2cdf79e.png</filename> <id>17246</id> <filesize>4538</filesize> <uploaded-timestamp>1227390768</uploaded-timestamp> </information> <links> <thumbs> <small>http://www.tehupload.com/thumbs/s/api-958768cb2cdf79e900528cb2cdf79e.png</small> <medium>http://www.tehupload.com/thumbs/m/api-958768cb2cdf79e900528cb2cdf79e.png</medium> <large>http://www.tehupload.com/thumbs/l/api-958768cb2cdf79e900528cb2cdf79e.png</large> </thumbs> <fullSize>http://www.tehupload.com/uploads/api-958768cb2cdf79e900528cb2cdf79e.png</fullSize> <share>http://www.tehupload.com/share/17246</share> </links> </content> </tehupload>
Logged in example:PHP Code:<?php
if($_GET ["action"] == "upload") {
$image = file_get_contents( $_FILES ["image"] ["tmp_name"] );
$image = urlencode( $image );
$curl = curl_init( "http://www.tehupload.com/api/upload.Image/" );
$postvars ["imageData"] = $image;
curl_setopt( $curl, CURLOPT_POST, 1 );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $postvars );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $curl, CURLOPT_HEADER, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$data = curl_exec( $curl ); // XML data returned..
$xml = new SimpleXMLElement( $data ); // data is now in XML object..
}
?>
<form enctype="multipart/form-data" action="?action=upload" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="image" type="file" />
<br/>
<input type="submit" value="Upload File" />
</form>
---------------------------------------PHP Code:<?php
if($_GET ["action"] == "upload") {
$image = file_get_contents( $_FILES ["image"] ["tmp_name"] );
$image = urlencode( $image );
$curl = curl_init( "http://www.tehupload.com/api/upload.Image/username=user&password=pass&album=1644" );
$postvars ["imageData"] = $image;
curl_setopt( $curl, CURLOPT_POST, 1 );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $postvars );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $curl, CURLOPT_HEADER, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$data = curl_exec( $curl ); // XML data returned..
$xml = new SimpleXMLElement( $data ); // data is now in XML object..
}
?>
<form enctype="multipart/form-data" action="?action=upload" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="image" type="file" />
<br/>
<input type="submit" value="Upload File" />
</form>
user.Info
---------------------------------------Parameters:Here is an example URL, with an example response:
username - TehUpload username
password - TehUpload password
Returns:
status - error, success
message - message relating to status
info
username - TehUpload username
email - TehUpload e-mail address
"registered-timestamp" - timestamp user registered on
fullName - user's full name (optional)
activated - is user activated? 1 = yes, 0 = no
totalUploads - total number of uploads to TehUpload
"lastLogin-timestamp" - timestamp of last loginoptionalmsn
yahoo
skype
aim
avatar - user avatar filename
biography
Code:http://www.tehupload.com/api/user.Info/username=username&password=passwordPHP Example:Code:<tehupload> <status>success</status> <message>credentials are correct</message> <content> <info> <username>BarryMingle</username> <email>[email protected]</email> <registered-timestamp>1217697357</registered-timestamp> <fullName>Barry Mingle</fullName> <activated>1</activated> <totalUploads>268</totalUploads> <lastLogin-timestamp>1226762615</lastLogin-timestamp> <optional> <msn></msn> <yahoo></yahoo> <skype></skype> <aim></aim> <avatar>5001a501d35f34224500bb3be8858fIMG_1647k.jpg</avatar> <biography></biography> </optional> </info> </content> </tehupload>
---------------------------PHP Code:<?php
$username = "Bob";
$password = "Jimbo";
$file = @file_get_contents( "http://www.tehupload.com/api/user.Info/username={$username}&password={$password}" );
$xml = new SimpleXMLElement( $file );
$email = $xml->content->info->email;
?>
Should be easy enough to integrate it into your application.
If you have any ideas for data that should be returned, or ideas for new methods to be incorporated, please let me know.
Thanks!
---------------------------





Reply With Quote

And Jack they already upload to yahoo I think 
