Dentafrice
22-11-2008, 10:00 PM
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:
username - TehUpload username
password - TehUpload password
Returns:
status - error, success
message - message relating to status
Here is an example URL, with an example response:
http://www.tehupload.com/api/check.credentials/username=username&password=password
<tehupload>
<status>error</status>
<message>credentials are incorrect</message>
</tehupload>
A successful response will return:
<tehupload>
<status>success</status>
<message>credentials are correct</message>
</tehupload>
PHP Example:
<?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:
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
images
info
filename - Image Filename
filetype - Image mime type
filesize - File size, in bytes
timestamp - Timestamp uploaded
album
display - is private album? 1 = no, 0 = yes
albumID - ID of the album image is in (album.getInfo)
links
full - link to full sized image
thumbs
small - link to small thumb
medium - link to medium thumb
large - link to large thumb
Here is an example URL, with an example response:
http://www.tehupload.com/api/get.Images/username=username&password=password&count=1
<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 Example:
<?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:
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
album
owner - owner userID
"owner-username" - owner username
title - album title
"default-image" - default image filename
private - is album private? 0 = no, 1 = yes
images
info
filename - image filename
filetype - mime filetype
filesize - filesize in bytes
timestamp - unix timestamp when uploaded
album
display - should it be shown on main page? private = 0
albumID - album that image is in
links
full - link to full sized image
thumbs
small - link to small thumb
medium - link to medium thumb
large - link to large thumbHere is an example URL, with an example response:
http://www.tehupload.com/api/album.getInfo/username=username&password=pass&albumID=165
<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 Example:
<?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:
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-)
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)
links
thumbs
small - link to small thumbnail
medium - link to medium thumbnail
large - link to large thumbnail
fullSize - link to fullSize image
share - link to share page (http://www.tehupload.com/share/id)
"album-share" (if usernam & password & album specified, returns share link to album)
Here is an example URL, with an example response:
http://www.tehupload.com/api/upload.Image/username=username&password=pass&album=165
<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>
PHP Example:
<?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>
Logged in example:
<?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:
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 login
optional
msn
yahoo
skype
aim
avatar - user avatar filename
biography
Here is an example URL, with an example response:
http://www.tehupload.com/api/user.Info/username=username&password=password
<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 Example:
<?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!
---------------------------
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:
username - TehUpload username
password - TehUpload password
Returns:
status - error, success
message - message relating to status
Here is an example URL, with an example response:
http://www.tehupload.com/api/check.credentials/username=username&password=password
<tehupload>
<status>error</status>
<message>credentials are incorrect</message>
</tehupload>
A successful response will return:
<tehupload>
<status>success</status>
<message>credentials are correct</message>
</tehupload>
PHP Example:
<?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:
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
images
info
filename - Image Filename
filetype - Image mime type
filesize - File size, in bytes
timestamp - Timestamp uploaded
album
display - is private album? 1 = no, 0 = yes
albumID - ID of the album image is in (album.getInfo)
links
full - link to full sized image
thumbs
small - link to small thumb
medium - link to medium thumb
large - link to large thumb
Here is an example URL, with an example response:
http://www.tehupload.com/api/get.Images/username=username&password=password&count=1
<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 Example:
<?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:
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
album
owner - owner userID
"owner-username" - owner username
title - album title
"default-image" - default image filename
private - is album private? 0 = no, 1 = yes
images
info
filename - image filename
filetype - mime filetype
filesize - filesize in bytes
timestamp - unix timestamp when uploaded
album
display - should it be shown on main page? private = 0
albumID - album that image is in
links
full - link to full sized image
thumbs
small - link to small thumb
medium - link to medium thumb
large - link to large thumbHere is an example URL, with an example response:
http://www.tehupload.com/api/album.getInfo/username=username&password=pass&albumID=165
<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 Example:
<?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:
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-)
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)
links
thumbs
small - link to small thumbnail
medium - link to medium thumbnail
large - link to large thumbnail
fullSize - link to fullSize image
share - link to share page (http://www.tehupload.com/share/id)
"album-share" (if usernam & password & album specified, returns share link to album)
Here is an example URL, with an example response:
http://www.tehupload.com/api/upload.Image/username=username&password=pass&album=165
<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>
PHP Example:
<?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>
Logged in example:
<?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:
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 login
optional
msn
yahoo
skype
aim
avatar - user avatar filename
biography
Here is an example URL, with an example response:
http://www.tehupload.com/api/user.Info/username=username&password=password
<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 Example:
<?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!
---------------------------