Created
March 7, 2011 21:10
-
-
Save sujee/859234 to your computer and use it in GitHub Desktop.
covercake webservice client PHP
This file contains 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 | |
$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