Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

covercake webservice client PHP

View gist:859234
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?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
Something went wrong with that request. Please try again.