Contents |
The base uri for AppData on MySpace is http://opensocial.myspace.com/roa/09/appdata. This endpoint supports GETs, PUTs, POSTs, and DELETEs.
The URI accepts parameters as part of the URI. URIs are of the following forms
This can be one of the following values:
This can be one of the following values:
This must be the application ID associated with the OAuth ConsumerKey/ConsumerSecret pair.
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 AppData 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/appData/@me/@self/135473
Response:
{ "entry":[ {"userAppData":{ "appData":[ {"key":"key1","value":"value1"}, {"key":"key2","value":"value2"}], "personId":"myspace.com.person.478499510"}}], "itemsPerPage":"1", "startIndex":"0", "totalResults":"1" }
/** * Get viewer's app data * @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(); $app_data_self_params = array( 'userId' => $userId, 'groupId' => '@self', 'appId' => '@app' ); $batch->add($osapi->appData->get($app_data_self_params), 'appdataSelf'); // 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: http://opensocial.myspace.com/roa/09/appData/@me/@self/135473?format=xml
Response:
<response xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <entry> <entry> <userAppData> <appData> <entry> <key>key2</key> <value>value2</value> </entry> <entry> <key>key1</key> <value>value1</value> </entry> </appData> <personId>myspace.com.person.478499510</personId> </userAppData> </entry> </entry> <itemsPerPage>1</itemsPerPage> <startIndex>0</startIndex> <totalResults>1</totalResults> </response>
Request: http://opensocial.myspace.com/roa/09/appData/@me/@self/135473?fields=test
Response:
{ "entry":[ {"userAppData":{ "appData":[ {"key":"test","value":"keyvalue"}], "personId":"myspace.com.person.478499510"}}], "itemsPerPage":"1", "startIndex":"0", "totalResults":"1" }
/** * Get viewer's app data * @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(); $app_data_self_params = array( 'userId' => '@me', 'groupId' => '@self', 'appId' => '@app', 'fields' => 'test' ); $batch->add($osapi->appData->get($app_data_self_params), 'appdataSelf'); // 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: http://opensocial.myspace.com/roa/09/appData/@me/@self/135473?fields=test&format=xml
Response:
<response xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <entry> <entry> <userAppData> <appData> <entry> <key>test</key> <value>keyvalue</value> </entry> </appData> <personId>myspace.com.person.478499510</personId> </userAppData> </entry> </entry> <itemsPerPage>1</itemsPerPage> <startIndex>0</startIndex> <totalResults>1</totalResults> </response>
Request: POST http://opensocial.myspace.com/roa/09/appData/@me/@self/135473?fields=test
{"userId":398672205, "appData":[{"key":"test","value":"whatever"}]}
Response:
{"statusLink":"http:\/\/opensocial.myspace.com\/roa\/09\/appdata\/myspace.com.person.495184236\/@self\/myspace.com.app.150086"}
/** * Update specific app data * @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(); // Update app data for the current user $update_params = array( 'userId' => '@me', 'groupId' => '@self', 'appId' => $appId, 'data' => array( 'osapiFoo1' => date("c") ) ); $batch->add($osapi->appData->update($update_params), 'updateAppData'); // 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: DELETE http://opensocial.myspace.com/roa/09/appData/@me/@self/135473?fields=test
Response:
200 OK
/** * Delete specific app data * @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(); $delete_params = array( 'userId' => '@me', 'groupId' => '@self', 'appId' => '@app', 'fields' => array('osapiFoo1') ); $batch->add($osapi->appData->delete($delete_params), 'deleteAppData'); // 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>"; } }