Search results for an API in php/json

Asked

Viewed 454 times

2

I am using the following API: http://api.elsevier.com/documentation/SCIDIRSearchAPI.wadl It is a database of books/ documents and I need to access there to get some records. I already have the registration and a key to use. The thing is, I’ve never done anything like this, and I don’t understand how this works. I have to make a connection to the webservice, okay? From there how to fetch this data?

They have an example here: http://apihtmlgen.elasticbeanstalk.com/sd_search.html . For now it was something like this that I want to do.

  • has a look at this site http://themekraft.com/getting-json-data-with-php-curl/ and at this http://stackoverflow.com/questions/15612/get-json-object-from-url I think you’ll find what you want. I’ve done this with other Apis, and the one that best met me was the response from the OS link.

1 answer

1

From what I can see here, this request sends an ajax to the site http://api.elsevier.com/content/search/ where you can put the parameters, for example, my test query was "hi":

http://api.elsevier.com/content/search/index:SCIDIR? query=oi&apiKey=4bc47d36effffe230fdb766b4e90a380&xml-Decode=true&httpAccept=application%2Fxml

This was the link that was generated by it, what you need to do is perform a post or get through a Curl or ajax see here:

In this case what you need to do is to recover what is returned, which is an xml, through a string. Then you can use PHP methods like the simplexml for read the returned xml and work with him.

If json is even easier, just use json.decode($retorno,TRUE); to transform the return you can catch through Curl:

In this case you don’t need to use javascript, it makes things a little simpler.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.