Contents |
The base uri for Albums on MySpace is http://opensocial.myspace.com/roa/09/albums. 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 albumId indicates which single album from the group identified by {selector} should be returned. This is used when an application wants to display a single album it created. Valid values are:
| 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 albums. |
| Viewer_access_to_private_videos_photos | View my private photos & videos | It will grant access to user’s private albums. [me and friendsonly] |
| Viewer_add_photos_to_albums | Allow this app to upload photos. | It will grant access to create albums. |
Note – the app can only request permissions 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. This section details how MySpace supports the standard query parameters for Albums.
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: GET http://opensocial.myspace.com/roa/09/albums/@supportedFields
Response:
["id","mediaItemCount","mediaType","ownerId","caption","thumbnailUrl","location","msPrivacyLevel"]
Request: GET 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>id</string> <string>mediaItemCount</string> <string>mediaType</string> <string>ownerId</string> <string>caption</string> <string>thumbnailUrl</string> <string>location</string> <string>msPrivacyLevel</string> </ArrayOfstring>
/** * Get supported fields. * @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->albums->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/albums/@me/@self
Response:
{"entry":[ {"album": {"caption":"Test Security", "id":"myspace.com.album.1224563", "thumbnailUrl":"http:\/\/c2.ac-images.myspacecdn.com\/images02\/16\/m_46e99190a67b4cedaecc4d9889c8ea25.jpg" } }], "itemsPerPage":1, "startIndex":1, "totalResults":2}
Request: GET http://opensocial.myspace.com/roa/09/albums/@me/@self?format=xml
Response:
<response xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <entry> <entry> <album> <caption>Test Security</caption> <id>myspace.com.album.1224563</id> <mediaItemCount>1</mediaItemCount> <mediaType>IMAGE</mediaType> <ownerId>398672205</ownerId> <thumbnailUrl>http://c2.ac-images.myspacecdn.com/images02/16/m_46e99190a67b4cedaecc4d9889c8ea25.jpg</thumbnailUrl> </album> </entry> </entry> <itemsPerPage>1</itemsPerPage> <startIndex>1</startIndex> <totalResults>2</totalResults> </response>
/** * Retrieve a list of albums for viewer * @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(); // Set Parameters (get 2 albums, and all fields) $user_params = array( 'userId' => $userId, 'groupId' => '@self', 'count' => 2, 'fields'=>'@all' ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->albums->get($user_params), 'get_albums'); // 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: PUT http://opensocial.myspace.com/roa/09/albums/@me/@self
{ "caption":"This is another test", "mediaItemCount":0}
Response:
{"statusLink": "http:\/\/opensocial.myspace.com\/roa\/09\/albums\/myspace.com.person.398672205\/@self\/myspace.com.album.1689899"}
/** * Create an album for viewer * @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(); $album = new osapiAlbum(); $album->setFields('caption', 'new album caption'); $user_params = array( 'userId' => '@me', 'groupId' => '@self', 'album' => $album ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->albums->create($user_params), 'create_album'); // 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 http://opensocial.myspace.com/roa/09/albums/@me/@self/myspace.com.album.1689899
{ "caption":"This is an update test", "id": "myspace.com.album.1689899", "mediaItemCount":0}
Response:
{"statusLink": "http:\/\/opensocial.myspace.com\/roa\/09\/albums\/myspace.com.person.398672205\/@self\/myspace.com.album.1689899"}
/** * Update an album for viewer * @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(); $album = new osapiAlbum(); $album->setFields('caption', 'updated album caption'); $user_params = array( 'userId' => '@me', 'groupId' => '@self', 'album' => $album, 'albumId'=>'myspace.com.album.3018169' ); // The second option in the $batch->add() assigns a request Id. $batch->add($osapi->albums->update($user_params), 'update_album'); // 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>"; } }