3.8 KiB
3.8 KiB
Open Photo API / Photo Upload
OpenPhoto, a photo service for the masses
Purpose of the Photo Upload API
This API is used to upload a new photo for a user.
Endpoint and parameters
/photo/upload.json
Parameters
- photo (required), The photo to be uploaded.
- This can be the binary photo in multipart/formdata
- This can be the base64 encoded value of the photo in application/x-www-form-urlencoded
- tags (optional), A comma delimited string of alpha numeric strings.
- returnOptions (optional), A string instructing a specific version of the photo to be autogenerated.
- 300x300 - A photo which maintains aspect ratio and fits inside a 300x300 square
- 1024x768xCR - A photo that's exactly 1024x768 pixels cropped to the center in an optimized manner
- 160x90xBWxCR - A photo that's cropped exactly to 160x90 in greyscale (black and white)
Response
The response is a Photo object.
{
"message":"Photo eo uploaded successfully",
"code":200,
"result":{
"tags":[
""
],
"hash":"6d7a9b0af31073a76ff2e79ee44b5c4951671fa2",
"status":"1",
"width":"4288",
"permission":"0",
"size":"0",
"dateTaken":"1309707719",
"height":"2848",
"views":"0",
"creativeCommons":"BY-NC",
"dateUploaded":"1311048094",
"pathBase":"\/base\/201107\/1311048062-opmew48QOp.jpg",
"pathOriginal":"\/original\/201107\/1311048062-opmew48QOp.jpg",
"host":"opme-test.s3.amazonaws.com",
"appId":"current.openphoto.me",
"dateUploadedMonth":"07",
"dateTakenMonth":"07",
"dateTakenDay":"03",
"exifCameraMake":"NIKON CORPORATION",
"dateUploadedYear":"2011",
"dateTakenYear":"2011",
"dateUploadedDay":"18",
"exifCameraModel":"NIKON D90",
"id":"eo"
}
}
Example
PHP
$ch = curl_init('http://jmathai.openphoto.me/photo/upload.json');
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
array('photo' => '@/path/to/photo.jpg', 'tags' => 'dog,cat', returnOptions' => '300x300')
);
curl_exec($ch);
Specification
Content type multipart/formdata
Preferred. You can post to this API using [multipart][multipart/formdata].
POST /photo/upload.json HTTP/1.1
Host: jmathai.openphoto.me
Content-Type: multipart/form-data; boundary=----------------SOMERANDOMSEPARATOR
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="tags"
disneyland,epcotcenter
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="longitude"
123.456
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="latitude"
135.246
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="photo";
filename="/path/to/your/photo.jpg"
Content-Type: image/gif
{your_binary_content_here}
-----------------------------SOMERANDOMSEPARATOR--
Content type application/x-www-form-urlencoded
You can post to this API using [urlencoded][application/x-www-form-urlencoded] and base64 encoding the photo.
POST /photo/upload.json HTTP/1.1
Host: jmathai.openphoto.me
photo=base64_encoded_string_representation_of_your_photo