Exemplo n.º 1
0
<?php

/*
	This example will set up a loop which listens to changes made to a bucket and display the changes on the screen.

	This can be handy for storing changes locally to a database, or for notifying users of any changes that have been made.

	This should be run from the command-line, not from a web browser.
*/
require_once dirname(__FILE__) . '/../Simperium/Simperium.php';
$simperium = new Simperium\Simperium('my-app-id', 'my-api-key');
$simperium->authorize('*****@*****.**', 'secret');
$cv = '';
$numTodos = 0;
$a = true;
while ($a) {
    $changes = $simperium->todo2->changes($cv, true);
    foreach ($changes as $change) {
        echo '<pre>' . print_r($change, true) . '</pre><hr />';
        $cv = $change->cv;
    }
}
Exemplo n.º 2
0
<?php

//	Simperium PHP library
require_once dirname(__FILE__) . '/../Simperium/Simperium.php';
$simperium = new Simperium\Simperium('my-app-id', 'my-api-key');
$token = $simperium->authorize('*****@*****.**', 'secret');
//	echo '<hr />';
echo '<h4>Add new data</h4>';
$todo1_id = $simperium->generate_uuid();
$simperium->todo2->post($todo1_id, array('text' => 'Watch Star Wars with K', 'done' => 'False'));
echo '<hr />';
echo '<h4>Get Index List</h4>';
$ret = $simperium->todo2->index();
$simperium->_debug($ret);
echo '<hr />';
echo '<h4>Get Index list and include data</h4>';
$ret = $simperium->todo2->index(true);
$simperium->_debug($ret);
echo '<hr />';
echo '<h4>Get Index list and then grab data from document</h4>';
foreach ($simperium->todo2->index()->index as $v) {
    echo $v->id . '<br />';
    $ret = $simperium->get($v->id);
    $simperium->_debug($ret);
}
echo '<hr />';
echo '<h4>Get item by unique id</h4>';
$ret = $simperium->todo2->get('61a27242-e268-4951-89b8-1d42b379d353');
$simperium->_debug($ret);
echo '<hr />';
echo '<h4>List All Buckets</h4>';