Reading REST API Response in PHP

I am trying to read Raven SEO Tools API. It is a REST API and currently it is serving the data backup as an XML (or JSON if I choose) when I just request the URL through a web browser. What is the best method to get the response from their server into my own PHP script for me to then play around with.

Any help much appreciated



If you only needs to retrieve a URL and parse its info. The easiest way is curl/JSON combination. Note that parsing JSON is faster than parsing XML.


Something simple as:

$url = "";
$ch = curl_init();
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 4);
$json = curl_exec($ch);
if(!$json) {
    echo curl_error($ch);

But if you need to call other methods from this API such as DELETE/PUT, etc. Then to have a REST client in PHP is more elegant solution. A comparison on those clients can be found in PHP REST Clients

I founded this code specifically for Raven API

Sample code:

require 'path/to/raventools-api-php/raventools-api-php.class.php';
$Raven = new RavenTools( 'B1DFC59CA6EC76FF' );
$method = 'domains';
$options = array('format'=> 'json');
$responseString = $Raven->getJSON($method, $options);

Need Your Help

Invoking UI thread from BeginGetResponse in Silverlight

.net silverlight windows-phone-7

I know how to do this in everyday .NET, but mucking round with WP7 development and Silverlight is driving me mad. An HttpWebRequest response must be done async, cool with that, but how can I invoke...

What do I need to use PayPal API?

e-commerce paypal

I a real noob when it comes to developing applications for PayPal. But, I have a client who needs me to build integration to paypal from his MVC website.