1. curl
- Posted by begin Jun 20, 2019
- 1172 views
hi everybody,
for a day now, i try to find a way to do that with phix and i can't get it done:
curl -LH "Accept: text/bibliography; style=bibtex" http://dx.doi.org/10.1038/nrd842 https://stackoverflow.com/questions/10507049/get-metadata-from-doi
does anybody have some code or an idea how to get the return?
thanks in advance.
2. Re: curl
- Posted by petelomax Jun 20, 2019
- 1141 views
enjoy:
include builtins\libcurl.e curl_global_init() atom curl = curl_easy_init() curl_easy_setopt(curl, CURLOPT_URL, "https://data.crossref.org/10.1038/nrd842") atom slist = curl_slist_append(NULL, "Accept: application/x-bibtex") slist = curl_slist_append(slist, "style=bibtex") curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist) object res = curl_easy_perform_ex(curl) if string(res) then ?res else ?"some error" end if curl_slist_free_all(slist) curl_easy_cleanup(curl) curl_global_cleanup()
Originally I did go to "http://dx.doi.org/10.1038/nrd842" but that just gave me the following response which it seems you might as well just cut out
"<html><head><title>Handle Redirect</title></head>\n<body><a href=\"https://data.crossref.org/10.1038%2Fnrd842\">https://data.crossref.org/10.1038%2Fnrd842</a></body></html>"
3. Re: curl
- Posted by begin Jun 21, 2019
- 1108 views
Hi Pete,
thank so very much for the code.
looking at it, in my endeavorers i did so many things wrong from the c examples, that it would have never worked.
thank you again
Richard