<!DOCTYPE html> <?php require_once './config.php'; //library credentials require_once '../build/libZoteroSingle.php'; $library = new \Zotero\Library($libraryType, $libraryID, $librarySlug, $apiKey); //load a couple items with multiple content types $items = $library->fetchItemsTop(array('limit' => 2, 'include' => 'data,bib')); ?> <html> <head> <title>Multi-Content</title> <meta charset="utf-8"> </head> <body> <h2>Multi-Content</h2> <?php foreach ($items as $item) { ?> <p>Citation:</p> <p><?php echo $item->bibContent; ?> </p> <p>JSON encoded metadata:</p> <p> <?php echo json_encode($item->apiObj['data']); ?> </p> <?php
//start at the beginning of our list by setting an offset of 0 $offset = 0; //limit to 100 items per http request //this is the maximum number of items the API will return in a single request $perRequestLimit = 20; //keep count of the items we've gotten $fetchedItemsCount = 0; //keep track of whether there are more items to fetch $moreItems = true; //where we'll keep the list of items we retrieve $items = array(); //while there are more items and we haven't gotten to our limit yet while ($fetchedItemsCount < $totalItemLimit && $moreItems) { echo "fetching items starting at {$offset} with {$perRequestLimit} items per request <br />"; //fetching items starting at $offset with $perRequestLimit items per request $fetchedItems = $library->fetchItemsTop(array_merge($params, array('limit' => $perRequestLimit, 'start' => $offset))); //put the items from this last request into our array of items $items = array_merge($items, $fetchedItems); //update the count of items we've got and offset by that amount $fetchedItemsCount += count($fetchedItems); $offset = $fetchedItemsCount; //Zotero\Library keeps track of the last response it got so we can check if there is a 'next' link //indicating more results to be fetched $links = $library->getLastResponse()->linkHeaders(); if (!isset($links['next'])) { $moreItems = false; } } //output the page ?> <!DOCTYPE html>
<!DOCTYPE html> <?php require_once './config.php'; //library credentials require_once '../build/libZoteroSingle.php'; $library = new \Zotero\Library($libraryType, $libraryID, $librarySlug, $apiKey); $library->setCacheTtl(90); //load a couple items with multiple content types $items = $library->fetchItemsTop(array('limit' => 10, 'include' => 'bib,citation,coins', 'linkwrap' => 1, 'style' => 'chicago-fullnote-bibliography')); ?> <html> <head> <title>Multi-Content</title> <meta charset="utf-8"> </head> <body> <h2>Bib-Content</h2> <?php foreach ($items as $item) { ?> <?php $doc = new DOMDocument(); $doc->loadXml($item->bibContent); $linkNodes = $doc->getElementsByTagName("a"); foreach ($linkNodes as $node) { $node->nodeValue = "Link"; } $newBibContent = $doc->saveXML(); ?> <p><?php echo $newBibContent;
<!DOCTYPE html> <?php //load credentials and library info from our config file require_once './config.php'; //load the zotero php library require_once '../build/libZoteroSingle.php'; //create a library object to interact with the zotero API $library = new \Zotero\Library($libraryType, $libraryID, $librarySlug, $apiKey); //use Alternative PHP Cache to save API responses for 30 minutes $library->setCacheTtl(1800); //fetch most recently added items from a collection //since the collection will never change we just use a hard coded collection key //that was set in our config file $items = $library->fetchItemsTop(array('limit' => 10, 'collectionKey' => $collectionKey, 'order' => 'dateAdded', 'sort' => 'desc')); //output the page //if the item has a url, we'll turn the title into a link ?> <html> <head> <title>Recent Items</title> <meta charset="utf-8"> </head> <body> <ul> <?php foreach ($items as $item) { ?> <li> <?php $url = $item->get('url');
<!DOCTYPE html> <?php require_once './config.php'; //library credentials require_once '../build/libZoteroSingle.php'; $library = new \Zotero\Library($libraryType, $libraryID, $librarySlug, $apiKey); //fetch subcollections of a collection $collections = $library->fetchCollections(array('collectionKey' => '', 'content' => 'json')); $collectionKey = ''; if (count($collections)) { $collectionKey = $collections[0]->collectionKey; } //fetch items from this library $items = $library->fetchItemsTop(array('limit' => 10, 'collectionKey' => $collectionKey)); ?> <html> <head> <title>Collection and Items</title> <meta charset="utf-8"> </head> <body> <h2>Collections</h2> <ul> <?php foreach ($collections as $collection) { ?> <li><?php echo $collection->name; ?> : <?php echo $collection->collectionKey;