MySpace Developer Platform

A Place For Developers
From MySpace Open Platform: Documentation Wiki

OpenSocial v0.9 Activities

Jump to: navigation, search

Contents

Base URI

The base uri for Activities on MySpace is http://opensocial.myspace.com/roa/09/activities. This endpoint supports both GET and POST requests.

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.

{selector}

The selector indicates which set of individuals to query for activities. Valid values are:

  • @self: This identifies a group of 1. The 1 is the person identified by {personId}.
  • @all | @friends: These values are synonyms. This value identifies the group containing all friends of {personId}.

{appId}

The appId indicates which set of activities from the group identified by {selector} should be returned. This is used when an application wants to display activities it created. Valid values are:

  • @app: Identifies the application that owns the (consumer key, consumer secret) pair used to authorize the call to the resource.
  • An integer value: Gives the integer identifier of the application. For example, Mobsters has the application ID 104283.

Notes

  • The following are the default fields for the Activities endpoint and will always be returned
    • id
    • title
  • The following fields are not supported by MySpace in OpenSocial 0.9
    • bodyId
    • priority
    • streamSourceUrl
    • streamTitle
    • streamUrl
    • any OpenSocial defined fields of templateParams
  • The following are MySpace extended fields of templateParams
    • msParameters

[NOTE –POST Activity endpoint uses this field to populate template parameters, please look at examples/SDKs to get more idea as to how it looks.]

  • The app must be installed to call any Activities endpoint.
  • POST Activity endpoint only works for @self requests and only if the person is the viewer.
  • ApplicationId in the URI and authorization context needs to be the same.
  • The following fields can be set for an activity creation request: titleId, msParameters of templateParams and msMediaItemUri of mediaItem(s). If titleId is not provided, it will return a 400 error.
  • Facts about FETCH Activities endpoints
    • It supports query parameter “updatedSince”, passing a valid value will return activities posted after that date and time.
    • It won’t include activities more than 60 days old.
    • If your request contains an appId, only activities related to that application will be returned. The maximum result set for this API include is 25.
    • If no app ID is specified, the response will contain normal MySpace activities, such as “User X uploaded a photo”, as well as application specific activities and status/mood updates. In this case, for all non-@self requests, the maximum number of activities that an app can request is 100 (count=100).
    • It won’t include birthdays, profile visits and profile updates in the result set.
  • Facts about POST Activities endpoints
    • To post images with an activity, populate the Activity’s MediaItem field with one to three MediaItem objects. Make sure the msMediaItemUri field is set for each MediaItem.
    • The app needs to have LIVE template(s) in order to create the acvitity. Learn everything you ever wanted to know about templates here:http://wiki.developer.myspace.com/index.php?title=Activity_Templates
  • Mobile URLs in Activity objects can be returned by appending wap=1 to the query-string.
  • In addition to having the app installed, the app needs the following permissions to access different Activities endpoints:
Permission Permission on App Settings page Notes
Viewer_show_updates_from_friends Receive activity updates from this app This permission gives access to all FETCH Activities endpoints.
Viewer_send_updates_to_friends Update my friends on my activities This permission grants access to POST Activity.
Viewer_access_to_friends_list App gets this permission automatically if app is installed This permission gives access to friends’ activities.

Note – the app can only request permission for the viewer.

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:
    • appid
    • body
    • externalid
    • id
    • mediaitems
    • postedtime
    • streamfaviconurl
    • title
    • titleid
    • userid
    • @all: A special value that tells the REST endpoint to send back all fields for the Activity.
  • 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: Indicates the date before which no activities should be returned.

Activity Streams Extensions

The MySpace OpenSocial 0.9 activities endpoints have recently added BETA support for Activity Streams objects represented in JSON and plain old XML. Find more information about Activity Streams on the web site.

  • actor: Describes the person who performed the activity.
  • context: Describes additional contextual information about an activity such as the actor's location when the activity was performed or their status and mood.
  • links: Contains the URL of an HTML-based representation of this activity, such as a photo page in the case of a photo upload activity.
  • objects: Contains information about the main object of the activity, such as a set of photos in the case of a photo upload activity.
  • source: Contains information from where the activity came. In the case of a playlist activity, it refers to the MySpace music channel page where the song was played.
  • target: Contains information about the target of the activity. The target is the object that the action was done to.
  • verbs: Defines an array of verb identifiers for this activity.


Activity Streams Extensions Schema

The following schema is a proposed extension the current OpenSocial 0.9 REST XSD for the Activity type.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://ns.opensocial.org/2008/opensocial" elementFormDefault="qualified" targetNamespace="http://ns.opensocial.org/2008/opensocial" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="Activity">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element minOccurs="0" name="actor" type="tns:ActivityObject" />
            <xs:element minOccurs="0" name="context" type="tns:ActivityContext" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="links" type="xs:string" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="objects" type="tns:ActivityObject" />
            <xs:element minOccurs="0" name="source" type="tns:ActivityObject" />
            <xs:element minOccurs="0" name="target" type="tns:ActivityObject" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="verbs" type="xs:string" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="ActivityObject">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element minOccurs="0" maxOccurs="unbounded" name="owner" type="tns:ActivityObject" />
            <xs:element minOccurs="0" name="detail" type="xs:string" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="links" type="xs:string" />
            <xs:element minOccurs="0" name="source" type="tns:ActivityObject" />
            <xs:element minOccurs="0" name="time" type="xs:string" />
            <xs:element minOccurs="0" name="id" type="xs:string" />
            <xs:element minOccurs="0" name="title" type="xs:string" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="objectTypes" type="xs:string" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="ActivityContext">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element minOccurs="0" maxOccurs="unbounded" name="location" type="tns:Address" />
        </xs:choice>
    </xs:complexType>
</xs:schema>

Activity Streams Sample JSON

"activity": {
    "actor": {
            "id": "tag:myspace.com,2009:/Person/81472123",
            "links": [
                "http://www.myspace.com/bmblack34"
            ],
            "objectTypes": [
                "http://activitystrea.ms/schema/1.0/person"
            ],
            "title": "Brandon Black"
    },
    "objects": [
        {
            "id": "tag:myspace.com,2009:/Photo/1816998/76453118",
            "links": [
                "http://c2.ac-images.myspacecdn.com/images02/6/s_be8bb90eebb4c8725724f66dcb9414f1.png"
            ],
            "source": {
                "id": "tag:myspace.com,2009:/Photo_Album/1816998",
                "title": "Misc"
            },
            "title": ""
        }
    ],
    "target": {
        "id": "tag:myspace.com,2009:/Photo_Album/1816998",
        "title": "Misc"
    },
    "verbs": [
        "http://activitystrea.ms/schema/1.0/post"
    ]
}

Examples

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

Retrieve all supported fields

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();
 
$batch->add($osapi->activities->getSupportedFields(), 'supportedFields');
 
// 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>";
    }
}

XML Response

Request: GET http://opensocial.myspace.com/roa/09/activities/@supportedFields?format=xml

Response:

<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <string>appId</string>
   <string>body</string>
   <string>externalId</string>
   <string>id</string>
   <string>mediaItems</string>
   <string>postedTime</string>
   <string>streamFaviconUrl</string>
   <string>title</string>
   <string>url</string>
   <string>userId</string>
   <string>actor</string>
   <string>context</string>
   <string>links</string>
   <string>objects</string>
   <string>source</string>
   <string>target</string>
   <string>verbs</string>
</ArrayOfstring>

JSON Response

Request: GET http://opensocial.myspace.com/roa/09/activities/@supportedFields?format=json

Response:

[
    "appId",
    "body",
    "externalId",
    "id",
    "mediaItems",
    "postedTime",
    "streamFaviconUrl",
    "title",
    "url",
    "userId",
    "actor",
    "context",
    "links",
    "objects",
    "source",
    "target",
    "verbs"
]

Retrieve all supported verbs

XML Response

Request: GET http://opensocial.myspace.com/roa/09/activities/@supportedVerbs?format=xml

Response:

<ArrayOfactivityVerb xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/post</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/share</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/save</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/play</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/make-friend</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/join</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/favorite</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/follow</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/tag</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/rsvp-yes</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/rsvp-no</uri>
   </activityVerb>
   <activityVerb>
      <uri>http://activitystrea.ms/schema/1.0/rsvp-maybe</uri>
   </activityVerb>
</ArrayOfactivityVerb>


Request: GET http://opensocial.myspace.com/roa/09/activities/@supportedVerbs?format=json

JSON Response

Response:

[
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/post"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/share"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/save"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/play"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/make-friend"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/join"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/favorite"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/follow"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/tag"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/rsvp-yes"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/rsvp-no"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/rsvp-maybe"
}
]


Retrieve all supported object types

XML Response

Request: GET http://opensocial.myspace.com/roa/09/activities/@supportedObjectTypes?format=xml

Response:

<ArrayOfactivityObjectType xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/person</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/group</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/file</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/photo</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/video</uri>
    </activityObjectType>
    <activityObjectType>
        <derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/video</uri>
        </derivesFrom>
        <uri>http://activitystrea.ms/schema/1.0/tv-episode</uri>
    </activityObjectType>
    <activityObjectType>
        <derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/video</uri>
        </derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/movie</uri>
    </activityObjectType>
    <activityObjectType>
        <derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/video</uri>
        </derivesFrom>
        <uri>http://activitystrea.ms/schema/1.0/video-podcast</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/audio</uri>
    </activityObjectType>
    <activityObjectType>
        <derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/audio</uri>
        </derivesFrom>
        <uri>http://activitystrea.ms/schema/1.0/audio-podcast</uri>
    </activityObjectType>
    <activityObjectType>
        <derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/audio</uri>
        </derivesFrom>
        <uri>http://activitystrea.ms/schema/1.0/song</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/bookmark</uri>
    </activityObjectType>
    <activityObjectType>
        <derivesFrom>
            <uri>http://activitystrea.ms/schema/1.0/bookmark</uri>
        </derivesFrom>
        <uri>http://activitystrea.ms/schema/1.0/review</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/article</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/blog-entry</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/note</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/event</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/photo-album</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/music-album</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/playlist</uri>
    </activityObjectType>
    <activityObjectType>
        <uri>http://activitystrea.ms/schema/1.0/place</uri>
    </activityObjectType>
</ArrayOfactivityObjectType>


Request: GET http://opensocial.myspace.com/roa/09/activities/@supportedObjectTypes?format=json

JSON Response

Response:

[
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/person"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/group"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/file"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/photo"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/video"
},
{
    "derivesFrom":
    {
        "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/video"
    },
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/tv-episode"
},
{
    "derivesFrom":
    {
        "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/video"
    },
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/movie"
},
{
    "derivesFrom":
    {
        "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/video"
    },
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/video-podcast"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/audio"
},
{
    "derivesFrom":
    {
        "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/audio"
    },
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/audio-podcast"
},
{
    "derivesFrom":
    {
        "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/audio"
    },
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/song"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/bookmark"
},
{
    "derivesFrom":
    {
        "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/bookmark"
    },
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/review"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/article"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/blog-entry"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/note"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/event"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/photo-album"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/music-album"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/playlist"
},
{
    "uri":"http:\/\/activitystrea.ms\/schema\/1.0\/place"
}
]

Retrieve viewer activities

Request: GET http://opensocial.myspace.com/roa/09/activities/@me/@self

Response:

{
  "entry":[
    {"activity":{"id":"myspace.com.activity.-1","title":"OpenSocial User uploaded a photo from a mobile phone:"}},
    {"activity":{"id":"myspace.com.activity.-1","title":"OpenSocial User uploaded a photo from a mobile phone:"}},
    {"activity":{"id":"myspace.com.activity.-1","title":"OpenSocial User added the OpenSocial SDK Test App app."}},
    {"activity":{"id":"myspace.com.activity.-1","title":"OpenSocial User added a new photo to the My Photos album."}}],
  "itemsPerPage":"22",
  "startIndex":"1"
}

PHP Sample

/**
 * Get viewer activities
 * @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',
  'count' => 10
);
$batch->add($osapi->activities->get($user_params), 'userActivities');
 
// 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 viewer's friends activities

Request: GET http://opensocial.myspace.com/roa/09/activities/@me/@friends

Response:

{
  "entry":[
    {"activity":{"id":"myspace.com.activity.-1","title":"Harakiro uploaded a photo from a mobile phone:"}},
    {"activity":{"id":"myspace.com.activity.-1","title":"Harakiro added the OpenSocial SDK Test App app."}},
  "itemsPerPage":"12",
  "startIndex":"1"
}

PHP Sample

/**
 * Get viewer's friends activities
 * @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' => '@friends',
  'count' => 10
);
$batch->add($osapi->activities->get($user_params), 'friendsActivities');
 
// 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>";
    }
}

Create an activity

Request with JSON: POST http://opensocial.myspace.com/roa/09/activities/@me/@self

{
    "externalId":"myExternalId",
    "id":"myspace.com.activity.-1",
    "title":"osapi test activity at",
    "body":"osapi test activity body",
    "templateParams":{
        "msParameters":[
        {
            "key":"friend",
            "value":"6221"
        },
        {
            "key":"content",
            "value":"hello there this is my template param content"
        }]
    },
    "titleId":"Template_4"
}

Response:

{
    "statusLink":"http:\/\/opensocial.myspace.com\/roa\/09\/activities\/myspace.com.person.495184236\/@self\/myspace.com.app.150086\/1251833666"
}

Request with XML: POST http://opensocial.myspace.com/roa/09/activities/@me/@self?format=xml

<Activity xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <externalId>myExternalId</externalId>
    <id>myspace.com.activity.-1</id>
    <title>osapi test activity at</title>
    <body>osapi test activity body</body>
    <templateParams>
        <msParameters>
            <entry>
                <key>friend</key>
                <value>6221</value>
            </entry>
            <entry>
                <key>content</key>
                <value>hello there this is my template param content</value>
            </entry>
        </msParameters>
    </templateParams>
    <titleId>Template_4</titleId>
</Activity>

Response:

<Result xmlns="http://ns.opensocial.org/2008/opensocial" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <statusLink>http://opensocial.myspace.com/roa/09/activities/myspace.com.person.478499510/@self/myspace.com.app.122603/1258067060</statusLink>
</Result>

PHP Sample

/**
 * Create an activity
 * @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();
 
// Create an activity (you could add osapiMediaItems to this btw)
$activity = new osapiActivity(null, null);
$activity->setField('title', 'osapi test activity at ' . time());
$activity->setField('body', 'osapi test activity body');
 
// Myspace requires some addtional things to be set.
$msParameters = array();
$msParameters[] = array("key"=>"content", "value"=>"hello there this is my template param content");
$msParameters[] = array("key"=>"friend", "value"=>"487802446");
$activity->setField('templateParams', $msParameters);
$activity->setField('titleId', 'Template_4');
 
 
$create_params = array(
  'userId' => $userId,
  'groupId' => '@self',
  'activity' => $activity,
  'appId' => $appId
);
$batch->add($osapi->activities->create($create_params), 'createActivity');
 
 
// 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>";
    }
}