Created
December 24, 2013 17:41
-
-
Save mdobson/8116084 to your computer and use it in GitHub Desktop.
Updated php sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('America/Detroit'); | |
//include autoloader to make sure all files are included | |
include '../autoloader.inc.php'; | |
usergrid_autoload('Apigee\\Usergrid\\Client'); | |
//initialize the SDK | |
$client = new Apigee\Usergrid\Client('crainsdetroit','cdbapp'); | |
//Need to login before doing anything for the sake of permissions | |
$client->login("USERNAME","PASSWORD"); | |
//reading data | |
$books = $client->get_collection('books'); | |
//do something with the data | |
while ($books->has_next_entity()) { | |
$book = $books->get_next_entity(); | |
$title = $book->get('title'); | |
echo "Next Book's title is: " . $title . "<br>"; | |
} | |
//writing data | |
$data = array('title' => 'the old man and the sea', 'type' => 'books'); | |
$book = $books->add_entity($data); | |
if ($book == FALSE) { | |
echo 'write failed'; | |
echo var_dump($book); | |
} else { | |
echo 'write succeeded'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment