MySpace Developer Platform

A Place For Developers
From MySpace Open Platform: Documentation Wiki

OpenSocial v0.9 Groups

Jump to: navigation, search

Contents

Base URI

The base uri for Activities on MySpace is http://opensocial.myspace.com/roa/09/groups. This endpoint supports GETs, PUTs, and POSTs.

URI Parameters

The URI accepts parameters as part of the URI. URIs are of the following forms

{personId}

This can be one of the following values:

  • @me: Refers to the current user. @me can only be passed in when using the xoauth_requestor_id query string parameter or when passing in an OAuth token.
  • An integer value: MySpace IDs are integers. For example, Tom is 6221. 6221 is a valid integer value.
  • myspace.com.person.[integer value]: PersonIDs also support type identifier prepended to the integer value. Tom's value is myspace.com.person.6221.

Notes

  • The group endpoint does not honor @fields query parameter. It will always populate id and title.
  • To make a call to this endpoint, the app needs to be installed.

Filtering Results

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.

  • count: Supported. Only returns the nearest multiple of 3 compared to the original value.
  • fields: Supported. Currently handles the following field names:
    • id
    • title
  • filterBy: Not supported.
  • filterOp: Not supported.
  • filterValue: Not supported.
  • format: Determines the format of the response. We currently support json and xml.
  • networkDistance: Not supported.
  • sortBy: Not supported.
  • sortOrder: Not supported.
  • startIndex: Indicates the index of the first item to retrieve from the query set.
  • updatedSince: Not supported. There is a bug report in to address this issue.

Examples

Like all OpenSocial endpoints, the groups endpoint requires OAuth parameters in all requests. The examples on this page do not show the OAuth parameters.

Retrieve all supported fields

Request: http://opensocial.myspace.com/roa/09/groups/@supportedFields

Response:

["id","title"]

PHP Sample

/**
 * Get groups
 * @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();
 
$batch->add($osapi->groups->getSupportedFields(), 'getSupportedFields');
 
// 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>";
    }
}

Retrieve all groups for current user

Request: http://opensocial.myspace.com/roa/09/groups/@me

Response:

{"entry":[
    {"group":
        {"id":"myspace.com.group.-9223308522498615704","title":"Bands"}
    },
    {"group":
        {"id":"myspace.com.group.-9223318821830191512","title":"Mobsters"}
    },
    {"group":
        {"id":"myspace.com.group.-9223315901252430232","title":"Outworld"}
    },
    {"group":
        {"id":"myspace.com.group.-9223333540683114904","title":"Test"}
    },
    {"group":
        {"id":"myspace.com.group.-9223329563543398808","title":"Work"}
    }],
 "itemsPerPage":"5",
 "startIndex":"1",
 "totalResults":"5"}

PHP Sample

/**
 * 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();
 
$user_params = array('userId' => $userId);
$batch->add($osapi->groups->get($user_params), 'getGroups');
 
// 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/activities/@me?format=xml

Response:

<response xmlns="http://ns.opensocial.org/2008/opensocial" 
          xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <entry>
    <entry>
      <group>
        <id>myspace.com.group.-9223350578799492787</id>
        <title>Applications</title>
      </group>
    </entry>
    <entry>
      <group>
        <id>myspace.com.group.-9223341675332288179</id>
        <title>This is a test</title>
      </group>
    </entry>
    <entry>
      <group>
        <id>myspace.com.group.-9223350591684394675</id>
        <title>Work</title>
      </group>
    </entry>
  </entry>
  <itemsPerPage>3</itemsPerPage>
  <startIndex>1</startIndex>
  <totalResults>3</totalResults>
</response>