Added:
/trunk/src/examples/profileComments.php
/trunk/src/osapi/service/osapiProfileComments.php
Modified:
/trunk/src/examples/index.php
/trunk/src/examples/notifications.php
/trunk/src/examples/statusmood.php
/trunk/src/osapi/io/osapiRequest.php
/trunk/src/osapi/io/osapiRestIO.php
/trunk/src/osapi/osapi.php
/trunk/src/osapi/providers/osapiMySpaceProvider.php
/trunk/src/osapi/service/osapiService.php
/trunk/src/osapi/service/osapiStatusMood.php
=======================================
--- /dev/null
+++ /trunk/src/examples/profileComments.php Wed Oct 28 12:15:35 2009
@@ -0,0 +1,47 @@
+<?php
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Default to myspace because this is a myspace specific endpoint.
+if(!isset($_REQUEST["test"]))
+ $_REQUEST["test"] = 'myspace';
+
+require_once "__init__.php";
+
+if ($osapi) {
+ if ($strictMode) {
+ $osapi->setStrictMode($strictMode);
+ }
+
+ // Start a batch so that many requests may be made at once.
+ $batch = $osapi->newBatch();
+
+ $user_params = array(
+ 'userId' => $userId
+ );
+
$batch->add($osapi->profileComments->get($user_params), 'getProfileComments');
+
+ // Send the batch request.
+ $result = $batch->execute();
+?>
+
+<h1>Messages Example</h1>
+<h2>Request:</h2>
+<p>This sample attempted to fetch a user's profile comments.</p>
+
+<?php
+ require_once('response_block.php');
+}
=======================================
--- /dev/null
+++ /trunk/src/osapi/service/osapiProfileComments.php Wed Oct 28 12:15:35
2009
@@ -0,0 +1,86 @@
+<?php
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * OpenSocial API class for Profile Comments requests
+ *
+ * @author Jesse Edwards
+ */
+class osapiProfileComments extends osapiService {
+ /**
+ * Gets a list of fields supported by this service
+ *
+ * @return osapiRequest the request
+ */
+ public function getSupportedFields() {
+ throw new osapiException("@supportedFields for statusmood is not
supported");
+ }
+
+ /**
+ * Gets status and mood. Uses specific endpoint for this
+ * Myspace specific
+ * @return osapiRequest the request
+ */
+ public function get($params)
+ {
+ if(!array_key_exists('userId', $params))
+ $params['userId'] = '@me';
+ if(!array_key_exists('groupId', $params))
+ $params['groupId'] = '@self';
+
+ return osapiRequest::createRequest('profilecomments.get', $params);
+ }
+ /**
+ * Sets status. Uses specific endpoint for this
+ * Myspace specific
+ * @return osapiRequest the request
+ */
+ public function update($params)
+ {
+ throw new osapiException("Updating this endpoint is not supported");
+ }
+
+ public function delete($params)
+ {
+ throw new osapiException("Deleting statusmood is not supported");
+ }
+
+ public function create($params)
+ {
+ throw new osapiException("Creating statusmood is not supported");
+ }
+
+ /**
+ * Converts a response into a native data type.
+ *
+ * @param array $array the raw data
+ * @param boolean $strictMode whether to throw spec errors
+ * @return osapiPerson
+ */
+ static public function convertArray($array, $strictMode = true) {
+ $instance = new osapiStatusMoodModel();
+ $defaults = get_class_vars('osapiStatusMoodModel');
+
+ if ($strictMode && sizeof($defaults != sizeof($array))) {
+ throw new osapiException("Unexpected fields in statusmood response".
print_r($array, true));
+ }
+ foreach($array as $key=>$value){
+ $instance->setField($key, $value);
+ }
+ return self::trimResponse($instance);
+ }
+}
=======================================
--- /trunk/src/examples/index.php Mon Aug 31 11:03:35 2009
+++ /trunk/src/examples/index.php Wed Oct 28 12:15:35 2009
@@ -22,8 +22,14 @@
<li><a href="albums.php">Albums</a> (only supported on 0.9 based
sites)</li>
<li><a href="mediaItems.php">MediaItems</a> (only supported on 0.9
based sites)</li>
<li><a href="groups.php">Groups</a> (only supported on 0.9 based
sites)</li>
- <li><a href="statusmood.php">StatusMood</a> (myspace only)</li>
- <li><a href="notifications.php">Notifications</a> (myspace only)</li>
+
+ </ul>
+
+ <h2>MySpace Extensions</h2>
+ <ul>
+ <li><a href="statusmood.php">StatusMood</a></li>
+ <li><a href="notifications.php">Notifications</a></li>
+ <li><a href="profileComments.php">Profile Comments</a></li>
</ul>
</body>
</html>
=======================================
--- /trunk/src/examples/notifications.php Thu Aug 27 13:27:24 2009
+++ /trunk/src/examples/notifications.php Wed Oct 28 12:15:35 2009
@@ -15,38 +15,42 @@
* limitations under the License.
*/
- require_once "__init__.php";
-
- if ($osapi) {
- if ($strictMode) {
- $osapi->setStrictMode($strictMode);
- }
-
- // Start a batch so that many requests may be made at once.
- $batch = $osapi->newBatch();
-
- // Set the status mood MySpace specific.
- $mediaItem = new osapiMediaItem();
-
$mediaItem->setField('uri', 'http://api.myspace.com/v1/users/63129100');
-
- $notification = new osapiNotification();
- $notification->setField('recipientIds', array('63129100'));
- $notification->setField('mediaItems', array($mediaItem));
- $notification->setTemplateParameter('content', 'Hi ${recipient},
here\'s a notification from ${canvasUrl}');
-
- $params = array('notification'=>$notification);
-
-
$batch->add($osapi->notifications->create($params), 'send_notification');
-
- // Send the batch request.
- $result = $batch->execute();
- ?>
-
- <h1>Notification API Examples</h1>
- <h2>Request:</h2>
- <p>This sample creates a notification(msypace specific)</p>
- <?php
-
- require_once('response_block.php');
- }
+// Default to myspace because this is a myspace specific endpoint.
+if(!isset($_REQUEST["test"]))
+ $_REQUEST["test"] = 'myspace';
+
+require_once "__init__.php";
+
+if ($osapi) {
+ if ($strictMode) {
+ $osapi->setStrictMode($strictMode);
+ }
+
+ // Start a batch so that many requests may be made at once.
+ $batch = $osapi->newBatch();
+
+ // Set the status mood MySpace specific.
+ $mediaItem = new osapiMediaItem();
+
$mediaItem->setField('uri', 'http://api.myspace.com/v1/users/63129100');
+
+ $notification = new osapiNotification();
+ $notification->setField('recipientIds', array('63129100'));
+ $notification->setField('mediaItems', array($mediaItem));
+ $notification->setTemplateParameter('content', 'Hi ${recipient},
here\'s a notification from ${canvasUrl}');
+
+ $params = array('notification'=>$notification);
+
+ $batch->add($osapi->notifications->create($params), 'send_notification');
+
+ // Send the batch request.
+ $result = $batch->execute();
+?>
+
+<h1>Notification API Examples</h1>
+<h2>Request:</h2>
+<p>This sample creates a notification(msypace specific)</p>
+<?php
+
+ require_once('response_block.php');
+}
?>
=======================================
--- /trunk/src/examples/statusmood.php Tue Sep 1 11:05:41 2009
+++ /trunk/src/examples/statusmood.php Wed Oct 28 12:15:35 2009
@@ -28,20 +28,37 @@
// Start a batch so that many requests may be made at once.
$batch = $osapi->newBatch();
+ $params = array('fields'=>'recentComments');
// Fetch the status mood MySpace specific.
- $batch->add($osapi->statusmood->get(array()), 'get_status_mood');
-
+ $batch->add($osapi->statusmood->get($params), 'get_status_mood');
+
+ // Fetch the status mood history self
+ $batch->add($osapi->statusmood->getHistory(), 'get_history_self');
+
+ $params = array('groupId'=>'@friends');
+
+ // Fetch the status mood history friends
+
$batch->add($osapi->statusmood->getHistory($params), 'get_history_friends');
+
+
+ // Fetch the status mood history specific friend
+ $params =
array('groupId'=>'@friends', 'friendId'=>'myspace.com.person.63129100');
+
$batch->add($osapi->statusmood->getHistory($params), 'get_history_friend');
+
+
// Set the status mood MySpace specific.
- $params = array('statusMood'=>
- array(
- 'moodName' =>'excited',
- 'status' => 'Working on PHP SDK'
- )
+ $params = array( 'userId'=>'@me',
+ 'groupId'=>'@self',
+ 'statusMood'=>
+ array(
+ 'moodName' =>'excited',
+ 'status' => 'Working on PHP SDK'
+ )
);
- $batch->add($osapi->statusmood->update($params), 'set_status_mood');
+ //$batch->add($osapi->statusmood->update($params), 'set_status_mood');
// Get one supported mood
- $params = array( 'userId'=>$userId,
+ $params = array( 'userId'=>'@me',
'groupId'=>'@supportedMood',
'moodId'=>90
);
@@ -60,7 +77,10 @@
<h1>StatusMood API Examples</h1>
<h2>Request:</h2>
- <p><b>NOTE: this entire endpoint a myspace extension to OpenSocial
v0.9.</b><br />This sample fetched statusmood, update statusmood, request a
specific moods details, then request all supported moods.</p>
+ <p><b>NOTE: This entire endpoint is a myspace extension to OpenSocial
v0.9.</b><br />
+ This sample fetched statusmood self and friends. Requested statusmood
history for self, friends, and a specific friend.
+ Then it can update statusmood (disabled by default). It also requests a
specific moods details,
+ then request all supported moods.</p>
<?php
require_once('response_block.php');
=======================================
--- /trunk/src/osapi/io/osapiRequest.php Mon Aug 31 11:03:35 2009
+++ /trunk/src/osapi/io/osapiRequest.php Wed Oct 28 12:15:35 2009
@@ -41,7 +41,7 @@
*/
public static function createRequest($method, $params) {
$availableServices =
array('people', 'activities', 'appdata', 'messages', 'system', 'cache',
- 'albums', 'mediaItems', 'statusmood', 'notifications', 'groups');
+ 'albums', 'mediaItems', 'statusmood', 'notifications', 'groups', 'profilecomments');
$availableMethods =
array('get', 'update', 'create', 'delete', 'upload',
'getSupportedFields', 'getSupportedMood');
=======================================
--- /trunk/src/osapi/io/osapiRestIO.php Mon Aug 31 11:03:35 2009
+++ /trunk/src/osapi/io/osapiRestIO.php Wed Oct 28 12:15:35 2009
@@ -33,8 +33,9 @@
'mediaItems'=>'mediaItems/{userId}/{groupId}/{albumId}/{mediaItemId}',
'groups'=>'groups/{userId}',
// MySpace Specific
- 'statusmood'=>'statusmood/{userId}/{groupId}/{moodId}',
- 'notifications'=>'notifications/{userId}/{groupId}'
+ 'statusmood'=>'statusmood/{userId}/{groupId}/{friendId}/{moodId}/{history}',
+ 'notifications'=>'notifications/{userId}/{groupId}',
+ 'profilecomments'=>'profilecomments/{userId}/{groupId}'
);
// Array used to resolve the method to the correct HTTP operation
=======================================
--- /trunk/src/osapi/osapi.php Mon Aug 31 11:03:35 2009
+++ /trunk/src/osapi/osapi.php Wed Oct 28 12:15:35 2009
@@ -63,7 +63,8 @@
'system' => 'osapiSystem',
'statusmood'=>'osapiStatusMood',
'notifications'=>'osapiNotifications',
- 'groups'=>'osapiGroups'
+ 'groups'=>'osapiGroups',
+ 'profilecomments'=>'osapiProfileComments'
);
/**
=======================================
--- /trunk/src/osapi/providers/osapiMySpaceProvider.php Tue Sep 29 12:43:51
2009
+++ /trunk/src/osapi/providers/osapiMySpaceProvider.php Wed Oct 28 12:15:35
2009
@@ -143,13 +143,14 @@
$data = json_decode($response['data']);
$service = $request->getService($request->method);
- $model = $plural_rules[$service];
+ $model = array_key_exists($service, $plural_rules) ?
$plural_rules[$service] : "null";
if (isset($data->entry)) {
+
foreach($data->entry as $key=>$value) {
if($model == 'appData') {
$data->entry[$key] = $value->{'userAppData'};
- } else {
+ } else if(isset($value->{$model})){
$data->entry[$key] = $value->{$model};
}
}
=======================================
--- /trunk/src/osapi/service/osapiService.php Mon Aug 31 11:03:35 2009
+++ /trunk/src/osapi/service/osapiService.php Wed Oct 28 12:15:35 2009
@@ -26,6 +26,7 @@
require_once "osapiStatusMood.php";
require_once "osapiNotifications.php";
require_once "osapiGroups.php";
+require_once "osapiProfileComments.php";
/**
* Abstract base class for the service definitions
=======================================
--- /trunk/src/osapi/service/osapiStatusMood.php Tue Sep 1 11:05:41 2009
+++ /trunk/src/osapi/service/osapiStatusMood.php Wed Oct 28 12:15:35 2009
@@ -35,14 +35,26 @@
return osapiRequest::createRequest('statusmood.getSupportedMood',
$params);
}
+ public function getHistory($params=array()) {
+ $params = array_merge($params,
array('userId'=>'@me', 'history'=>'history'));
+
+ if(!array_key_exists('groupId', $params))
+ $params['groupId'] = '@self';
+
+ return osapiRequest::createRequest('statusmood.get', $params);
+ }
/**
* Gets status and mood. Uses specific endpoint for this
* Myspace specific
* @return osapiRequest the request
*/
public function get($params)
- {
- $params = array_merge($params,
array('userId'=>'@me', 'groupId'=>'@self'));
+ {
+ if(!array_key_exists('userId', $params))
+ $params['userId'] = '@me';
+ if(!array_key_exists('groupId', $params))
+ $params['groupId'] = '@self';
+
return osapiRequest::createRequest('statusmood.get', $params);
}
/**