protected function get_pika_link($isbn)
 {
     require_once 'pika-api.php';
     $pikaHandler = new Pika_API();
     $response = $pikaHandler->getTitlebyISBN($isbn);
     if (!empty($response)) {
         $links = array();
         $results = json_decode($response, true);
         foreach ($results['result'] as $resultItem) {
             if (!empty($resultItem['id'])) {
                 $links[] = 'http://' . $pikaHandler->base_url . '/GroupedWork/' . $resultItem['id'] . '/Home';
                 //TODO: set protocol dynamically
             }
         }
         return $links;
     } else {
         return false;
     }
 }
Beispiel #2
0
     }
 }
 // We need to add titles to the list
 //Get a list of titles from NYT API
 $availableListsRaw = $nyt_api->get_list($selectedList);
 $availableLists = json_decode($availableListsRaw);
 $listPikaIDs = array();
 foreach ($availableLists->results as $titleResult) {
     // go through each list item
     if (!empty($titleResult->isbns)) {
         foreach ($titleResult->isbns as $isbns) {
             $isbn = empty($isbns->isbn13) ? $isbns->isbn10 : $isbns->isbn13;
             if ($isbn) {
                 //look the title up in Pika by ISBN
                 require_once 'pika-api.php';
                 $pikaHandler = new Pika_API();
                 $response = $pikaHandler->getTitlebyISBN($isbn);
                 if (!empty($response)) {
                     $results = json_decode($response, true);
                     foreach ($results['result'] as $resultItem) {
                         if (!empty($resultItem['id'])) {
                             $pikaID = $resultItem['id'];
                             $listPikaIDs[$pikaID] = $pikaID;
                             break;
                         }
                     }
                 }
             }
             //todo break if we found a pika id for the title (jordan)
         }
     }