Today I tried to query Zotero’s REST API with PHP to retrieve a list of my bibliography items for further processing. The basics are pretty easy setup using phpZotero and following this guide: Mashup Guide :: Zotero REST API: early developments.
However, I ran into some problems as the user id could be read by getUserId() but getUserItems() returned an empty item list. I found the solution after analyzing the request URLs: the user id is read using HTTP while all the other functions use HTTPS. So I simply added these two lines to httpRequest() to avoid checking the server certificate: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
Furthermore, the name of the parameter for the API key is not apiKey but key. So the URL pointing to my bibliography items has to be https://api.zotero.org/users/{USERID}/items/?key={APIKEY} (you don’t need username). Although the API key is passed to phpZotero’s constructor, the class doesn’t use it in any of its HTTP calls, so I added this line to zoteroRequest():
$request .= '?key=' . $this->apiKey;
After theses small changes my items could be read successfully.
Would you mind publishing your php-files? Where would I find the output of your library?
Best wishes
@Klaus: See my Zotero Plugin for DokuWiki for an example on how to use the Zotero API.