Mercurial > hg > ywww
view goodreads/addToShelf.php @ 23:d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
author | Charlie Root |
---|---|
date | Sun, 30 Dec 2018 07:00:09 -0500 |
parents | 077b0a0a3e6d |
children |
line wrap: on
line source
<?php require_once('GoodreadsAPI.php'); session_start(); $isbn=$_GET['isbn']; $shelf=$_GET['shelf']; $url= "http://www.goodreads.com/book/isbn?isbn=" . $isbn . "&key=8vxmKmAn8AVolobtvBbMIg"; $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_ENCODING , "gzip"); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); $ret = preg_replace("/[^[:alnum:][:punct:][:space:]]/","",$ret); $xml = new SimpleXMLElement($ret); $book_id = $xml->book->id; echo $book_id; $access_token = $_SESSION['access_token']; print_r($access_token); $obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); $content = $obj->doPost('http://www.goodreads.com/shelf/add_to_shelf.xml', array("name" => "$shelf", "book_id" => "$book_id")); print_r($content); unset ($obj); ?>