Prototype for "Radically Simplify the Persistence API" RPC/REST
View the source of this page |
View the patch to PHP Shindig |
Show pretty output
newBatch();
$create_params = array(
'userId' => '@me',
'groupId' => '@self',
'appId' => '@app',
'data' => array(
'foo1' => $foo1,
'foo2' => $foo2,
'foo3' => $foo3
)
);
$batch->add($osapi->appdata->create($create_params), 'create_appdata');
$result = $batch->execute();
?>
Creating App Data using the old syntax
Setting the foo1 parameter to a random number: = $foo1 ?>
Setting the foo2 parameter to the current date: = $foo2 ?>
Setting the foo3 parameter to a string: = $foo3 ?>
getRequestBody(), True)); ?>
= $http_provider->getRequestUrl(); ?>
= $http_provider->getRequestBody(); ?>
getResponseBody(), True)); ?>
= $http_provider->getResponseBody(); ?>
newBatch();
$self_request_params = array(
'userId' => '@me',
'groupId' => '@self',
'fields' => array(
'aboutMe',
'bodyType',
'currentLocation',
'happiestWhen',
'lookingFor',
'appData',
)
);
$batch->add($osapi->people->get($self_request_params), 'get_self');
$result = $batch->execute();
?>
Getting the viewer and all app data using the new syntax
App data returned was = htmlentities(json_encode($result['get_self']->getAppData())) ?>
getRequestBody(), True)); ?>
= $http_provider->getRequestUrl(); ?>
= $http_provider->getRequestBody(); ?>
getResponseBody(), True)); ?>
= $http_provider->getResponseBody(); ?>
newBatch();
$self_request_params = array(
'userId' => '@me',
'groupId' => '@self',
'fields' => array(
'appData.foo1',
'appData.foo2'
)
);
$batch->add($osapi->people->get($self_request_params), 'get_appdata_by_key');
$result = $batch->execute();
$result_data = $result['get_appdata_by_key']->getAppData();
?>
Fetching App Data by specific keys
Requested the foo1 parameter: = htmlentities($result_data['foo1']) ?>
Requested the foo2 parameter: = htmlentities($result_data['foo2']) ?>
getRequestBody(), True)); ?>
= $http_provider->getRequestUrl(); ?>
= $http_provider->getRequestBody(); ?>
getResponseBody(), True)); ?>
= $http_provider->getResponseBody(); ?>
newBatch();
$self_request_params = array(
'userId' => '@me',
'groupId' => '@friends',
'fields' => array(
'appData.foo1',
'appData.foo2',
'appData.foo3',
)
);
$batch->add($osapi->people->get($self_request_params), 'get_friends');
$result = $batch->execute();
?>
Fetching App Data for the current user's friends
(For this to work, you'll need friends who have run this sample. You'll need
to register additional test accounts or friend
Alice Testington,
API Kurrik, or
Arne)
getList() as $friend): ?>
getAppData(); ?>
= $friend->getDisplayName() ?> has appdata:
$value): ?>
= htmlentities($key) ?> = = htmlentities($value) ?>
getRequestBody(), True)); ?>
= $http_provider->getRequestUrl(); ?>
= $http_provider->getRequestBody(); ?>
getResponseBody(), True)); ?>
= $http_provider->getResponseBody();
echo "";
?>