Contents |
The base uri for MediaItems on MySpace is http://opensocial.myspace.com/roa/09/mediaItems. This endpoint supports GETs, PUTs, and POSTs.
The URI accepts parameters as part of the URI. URIs are of the following forms
This can be one of the following values:
The selector indicates which set of individuals to query for albums. Valid values are:
The albumId indicates which group of media items from a single album from the group identified by {selector} should be returned. This is used when an application wants to display the contents of a single album. Valid values are:
The mediaItemId indicates which single media item from the album identified by {albumId} should be returned. This is used when an application wants to display a single mediaItem. Valid values are:
The specific video category that you want to retrieve data about.
| Permission | Permission on App Settings page | Notes |
| Viewer_access_to_public_videos_photos | App gets this permission automatically if app is installed. | It will grant access to user’s public images/videos. |
| Viewer_access_to_private_videos_photos | View my private photos & videos | It will grant access to user’s private images/videos. [me and friendsonly] |
| Viewer_add_photos_to_albums | Allow this app to upload photos. | It will grant access to upload images/videos. |
Note – the app can only request permission for the viewer.
OpenSocial supports a set of standard query parameters for filtering data. Depending on the endpoint, different sets of query parameters are supported with different, well known values.
Like all OpenSocial endpoints, the albums endpoint requires OAuth parameters in all requests. The examples on this page do not show the OAuth parameters.
Request: http://opensocial.myspace.com/roa/09/albums/@supportedFields
Response:
["albumId","created","description","duration","id","language","mimeType","numComments","numViews","numVotes","rating","tags","thumbnailUrl","title","type","url"]
Request: http://opensocial.myspace.com/roa/09/albums/@supportedFields?format=xml
Response:
<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <string>albumId</string> <string>created</string> <string>description</string> <string>duration</string> <string>id</string> <string>language</string> <string>mimeType</string> <string>numComments</string> <string>numViews</string> <string>numVotes</string> <string>rating</string> <string>tags</string> <string>thumbnailUrl</string> <string>title</string> <string>type</string> <string>url</string> </ArrayOfstring>
/** * Get supported fields for mediaItems * @using osapi PHP SDK */ require_once "osapi/osapi.php"; $appKey = '<app key>'; $appSecret = '<app secret>'; $userId = '<userId>'; $osapi = new osapi(new osapiMySpaceProvider(), new osapiOAuth2Legged($appKey, $appSecret, $userId)); $batch = $osapi->newBatch(); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->mediaItems->getSupportedFields(), 'supported_fields'); // Send all batched commands $result = $batch->execute(); // Demonstrate iterating over a response set, checking for an error & working with the result data. foreach ($result as $key => $result_item) { if ($result_item instanceof osapiError) { echo "<h2>There was a <em>".$result_item->getErrorCode()."</em> error with the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities($result_item->getErrorMessage())."</pre>"; } else { echo "<h2>Response for the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities(print_r($result_item, True))."</pre>"; } }
Request: GET http://opensocial.myspace.com/roa/09/mediaItems/@me/@self/myspace.com.album.1224563?xoauth_requestor_id=398672205
Response:
{"entry":[ {"mediaItem": {"id":"myspace.com.mediaItem.image.14002385", "thumbnailUrl":"http:\/\/c2.ac-images.myspacecdn.com\/images02\/16\/s_46e99190a67b4cedaecc4d9889c8ea25.jpg", "title":"","type":"IMAGE", "url":"http:\/\/c2.ac-images.myspacecdn.com\/images02\/16\/l_46e99190a67b4cedaecc4d9889c8ea25.jpg"}}], "itemsPerPage":"1", "startIndex":"1", "totalResults":"1"}
<?php /** * Get mediaItems for album * @using osapi PHP SDK */ require_once "osapi/osapi.php"; $appKey = '<app key>'; $appSecret = '<app secret>'; $userId = '<userId>'; $osapi = new osapi(new osapiMySpaceProvider(), new osapiOAuth2Legged($appKey, $appSecret, $userId)); $batch = $osapi->newBatch(); $user_params = array( 'userId' => $userId, 'groupId' => '@self', 'albumId' =>'myspace.com.mediaItem.3007062', 'count' => 2 ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->mediaItems->get($user_params), 'get_mediaItems'); // Send all batched commands $result = $batch->execute(); // Demonstrate iterating over a response set, checking for an error & working with the result data. foreach ($result as $key => $result_item) { if ($result_item instanceof osapiError) { echo "<h2>There was a <em>".$result_item->getErrorCode()."</em> error with the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities($result_item->getErrorMessage())."</pre>"; } else { echo "<h2>Response for the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities(print_r($result_item, True))."</pre>"; } } ?>
Request: GET /roa/09/mediaItems/@me/@self/myspace.com.album.1224563/myspace.com.mediaItem.image.14002385?xoauth_requestor_id=398672205 HTTP/1.1
Response:
{"itemsPerPage":"1", "mediaItem":{ "id":"myspace.com.mediaItem.image.14002385", "thumbnailUrl":"http:\/\/c2.ac-images.myspacecdn.com\/images02\/16\/s_46e99190a67b4cedaecc4d9889c8ea25.jpg", "title":"", "type":"IMAGE", "url":"http:\/\/c2.ac-images.myspacecdn.com\/images02\/16\/l_46e99190a67b4cedaecc4d9889c8ea25.jpg"}, "startIndex":"0", "totalResults":"1"}
/** * Get a specific mediaItem * @using osapi PHP SDK */ require_once "osapi/osapi.php"; $appKey = '<app key>'; $appSecret = '<app secret>'; $userId = '<userId>'; $osapi = new osapi(new osapiMySpaceProvider(), new osapiOAuth2Legged($appKey, $appSecret, $userId)); $batch = $osapi->newBatch(); $user_params = array( 'userId' => $userId, 'groupId' => '@self', 'fields'=>'@all', 'albumId' =>'myspace.com.mediaItem.3007062', 'mediaItemId'=>'myspace.com.mediaItem.image.52894964' ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->mediaItems->get($user_params), 'get_mediaItems_id'); // Send all batched commands $result = $batch->execute(); // Demonstrate iterating over a response set, checking for an error & working with the result data. foreach ($result as $key => $result_item) { if ($result_item instanceof osapiError) { echo "<h2>There was a <em>".$result_item->getErrorCode()."</em> error with the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities($result_item->getErrorMessage())."</pre>"; } else { echo "<h2>Response for the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities(print_r($result_item, True))."</pre>"; } }
Request:
POST /roa/09/mediaItems/@me/@self/myspace.com.album.1224563?xoauth_requestor_id=398672205&type=IMAGE&caption={optional_parameter} HTTP/1.1
Host: opensocial.myspace.com
Accept: */*
Content-Type: image/jpeg
Authorization: OAuth realm="",oauth_version="1.0",oauth_nonce="e394f964b861da384b5aff543febd184",oauth_timestamp="1247183541",oauth_consumer_key="http%3A%2F%2Fwww.myspace.com%2F422699854",oauth_signature_method="HMAC-SHA1",oauth_signature="[it's a secret]"
Content-Length: 125586
[JPEG is here, contents elided]Response:
{"statusLink":"http:\/\/opensocial.myspace.com\/roa\/09\/mediaitems\/myspace.com.person.398672205\/@self\/myspace.com.album.1224563\/myspace.com.mediaItem.image.14002385"}
/** * Upload Photo * @using osapi PHP SDK */ require_once "osapi/osapi.php"; $appKey = '<app key>'; $appSecret = '<app secret>'; $userId = '<userId>'; $osapi = new osapi(new osapiMySpaceProvider(), new osapiOAuth2Legged($appKey, $appSecret, $userId)); $batch = $osapi->newBatch(); // Load file binary data $data = file_get_contents('images.jpg'); $user_params = array( 'userId' => '@me', 'groupId' => '@self', 'albumId' =>'myspace.com.mediaItem.3007062', 'mediaType'=>'IMAGE', 'mediaItem' => $data, 'contentType'=> 'image/jpg' ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->mediaItems->uploadContent($user_params), 'upload_mediaItem'); // Send all batched commands $result = $batch->execute(); // Demonstrate iterating over a response set, checking for an error & working with the result data. foreach ($result as $key => $result_item) { if ($result_item instanceof osapiError) { echo "<h2>There was a <em>".$result_item->getErrorCode()."</em> error with the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities($result_item->getErrorMessage())."</pre>"; } else { echo "<h2>Response for the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities(print_r($result_item, True))."</pre>"; } }
Request: POST /roa/09/mediaItems/@me/@self/myspace.com.album.1224563/myspace.com.mediaItem.image.14002385?xoauth_requestor_id=398672205
{ "title":"This is a new title" }
Response:
{"statusLink":"http:\/\/opensocial.myspace.com\/roa\/09\/mediaitems\/myspace.com.person.398672205\/@self\/myspace.com.album.1224563\/myspace.com.mediaItem.image.14002385"}
/** * Update Media Item then get newly updated mediaItem * @using osapi PHP SDK */ require_once "osapi/osapi.php"; $appKey = '<app key>'; $appSecret = '<app secret>'; $userId = '<userId>'; $osapi = new osapi(new osapiMySpaceProvider(), new osapiOAuth2Legged($appKey, $appSecret, $userId)); $batch = $osapi->newBatch(); $mediaItem = new osapiMediaItem(); $mediaItem->setFields('title', 'title '.time()); $user_params = array( 'userId' => '@me', 'groupId' => '@self', 'albumId' =>'myspace.com.mediaItem.3007062', 'mediaItemId'=>'myspace.com.mediaItem.image.52894964', 'mediaItem' => $mediaItem ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->mediaItems->update($user_params), 'update_mediaItem'); $user_params = array( 'userId' => '@me', 'groupId' => '@self', 'albumId' =>'myspace.com.mediaItem.3007062', 'mediaItemId'=>'myspace.com.mediaItem.image.52894964' ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->mediaItems->get($user_params), 'get_mediaItem'); // Send all batched commands $result = $batch->execute(); // Demonstrate iterating over a response set, checking for an error & working with the result data. foreach ($result as $key => $result_item) { if ($result_item instanceof osapiError) { echo "<h2>There was a <em>".$result_item->getErrorCode()."</em> error with the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities($result_item->getErrorMessage())."</pre>"; } else { echo "<h2>Response for the <em>$key</em> request:</h2>"; echo "<pre>".htmlentities(print_r($result_item, True))."</pre>"; } }