0

Which is the best method to get response from a web service URL? for example, we can use cURL, file_get_contents, file, .. to get response. Can anybody help me to find a best one?

3
Contributors
5
Replies
7
Views
8 Years
Discussion Span
Last Post by mschroeder
0

Depends on your needs. If you only need GET parameters then file_get_contents should be fine. cURL on the other hand allows for much more customization in headers sent.

0

I will get an XML response from my web service. So in my site I want call my web service to get XML response and parse it. It is a search web service. So when users search, I will call this service. So it must be very faster. which is better way? file_get_contents() or cURL or anu other?

0

Are there parameters and if so do they need passed via GET or POST requests?

cURL will allow for GET and POST requests, but file_get_contents will only be able to open urls that can accept GET requests.

Since you're parsing XML and 90% of the web services I see work with GET requests I'm going to take a shot in the dark and recommend using SimpleXML to do both at the same time.

Here is a pretty good tutorial on parsing xml retrieved from a url with SimpleXML: http://www.ibm.com/developerworks/library/x-simplexml.html

0

Thanks...

I am using GET request and passing parameters. Can you please tell me file_get_contents() or cURL is better performance?

0

SimpleXML as it will eliminate having to first load the contents with either cURL or file_get_contents and then having to load that data into SimpleXML or the DOM to then parse the XML.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.