Skip to content

Instantly share code, notes, and snippets.

@sujee
Created March 7, 2011 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sujee/859234 to your computer and use it in GitHub Desktop.
Save sujee/859234 to your computer and use it in GitHub Desktop.
covercake webservice client PHP
<?php
$API_KEY="api_key_here";
$response = file_get_contents("https://covercake.com/api/v1/feeds?key=$API_KEY");
$j = json_decode($response);
#var_dump($j);
if (strcasecmp($j->status, "OK") != 0)
{
echo "error accessing webservice: " . $j->status_text;
exit;
}
# get feeds, pick a random feed
$feed1 = $j->feeds[4];
#var_dump($feed1);
echo "Feed: " . $feed1->name. "\n";
#get feed info
$response = file_get_contents("https://covercake.com/api/v1/feed_info?key=$API_KEY&id=" . $feed1->id);
$j = json_decode($response);
if (strcasecmp($j->status, "OK") != 0)
{
echo "error accessing webservice: " . $j->status_text;
exit;
}
$featuring = $j->featurings[0];
$book = $featuring->book;
echo "Featured Date: " . $featuring->featured_date . ", book: " . $book->title . "\n";
#get book info
$response = file_get_contents("https://covercake.com/api/v1/book_info?key=$API_KEY&id=" . $book->id);
$j = json_decode($response);
if (strcasecmp($j->status, "OK") != 0)
{
echo "error accessing webservice: " . $j->status_text;
exit;
}
$book = $j->book;
echo "Book isbn : " . $book->isbn10 . "\n";
echo "This book has been featured " . count($j->featurings) . " times\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment