I’m trying to pull some data into my CakePHP site using a REST API. I’m familiar with CakePHP, but not with REST, so I’d like some guidance as to the best way to do this. I’ve looked online, but a lot of what I find is either telling me how to make my own API, or it’s quite old, and I’m not sure if it’s still relevant.
The API documentation tells me to make the query request
http://api.sitename.com/rest/organizations/my_id/media.xml
where my_id is a string that I have.
I’m using:
$url = http://api.sitename.com/rest/organizations/my_id/media.xml;
$result = file_get_contents($url);
and then I have the XML in $result.
Is this the best way to do this?
Short, direct answer to:
No
Head over to the PHP cURL documenation for more info on how to “talk” to public web services.