if ($createAttachmentResponse->isError()) { echo $createAttachmentResponse->getStatus() . "\n"; echo $createAttachmentResponse->getBody() . "\n"; die("Error creating attachment item\n\n"); } else { //read new item we created $createdAttachmentFeed = new Zotero_Feed($createAttachmentResponse->getBody()); $createdAttachment = $library->items->addItemsFromFeed($createdAttachmentFeed); $createdAttachment = $createdAttachment[0]; echo "attachment item created \n"; //upload file for attachment $fileContents = file_get_contents('./zotero_sticker.ai'); $fileinfo = array('md5' => md5($fileContents), 'filename' => 'zotero_sticker.ai', 'filesize' => filesize('./zotero_sticker.ai'), 'mtime' => filemtime('./zotero_sticker.ai')); echo "<br /><br />\n\nFile Info:"; var_dump($fileinfo); $res = $library->uploadNewAttachedFile($createdAttachment, $fileContents, $fileinfo); if ($res) { echo "successfully uploaded file\n"; } else { $errResponse = $library->getLastResponse(); echo $errResponse->getStatus() . "\n"; echo $errResponse->getBody() . "\n"; die("Error uploading file\n\n"); } } } catch (Exception $e) { echo $e->getMessage(); $lastResponse = $library->getLastResponse(); echo $lastResponse->getStatus() . "\n"; echo $lastResponse->getRawBody() . "\n"; }
</form> <?php error_reporting(E_ALL | E_STRICT); ini_set('display_startup_errors', 1); ini_set('display_errors', 1); require_once '../build/libZoteroSingle.php'; if (!empty($_POST)) { $libraryID = $_POST['libraryID']; $libraryType = $_POST['libraryType']; $apiKey = $_POST['apiKey']; $starredJson = file_get_contents($_FILES['jsonfile']['tmp_name']); $zlib = new Zotero_Library($libraryType, $libraryID, '', $apiKey); $starredCollection = $zlib->createCollection('Google Reader Starred'); if ($starredCollection === false || $starredCollection->writeFailure != false) { print "<p>Error creating collection</p>"; var_dump($zlib->getLastResponse()); var_dump($starredCollection->writeFailure); die; } print "<p>New Zotero collection created for google reader starred items with collectionKey {$starredCollection->get('collectionKey')}</p>"; //read the starred items from the json and create a Zotero item for each one $starredObject = json_decode($starredJson, true); $starredReaderItems = $starredObject['items']; $zItems = array(); foreach ($starredReaderItems as $readerItem) { print "<p>Reader starred item: {$readerItem['title']}</p>"; $item = $zlib->getTemplateItem('webpage'); $item->set('title', $readerItem['title']); $item->set('date', date('Y-m-d', $readerItem['published'])); $item->addCreator(array('creatorType' => 'author', 'name' => $readerItem['author'])); if (array_key_exists('content', $readerItem) && array_key_exists('content', $readerItem['content'])) {