PHP API Example for Retrieving Information
I have seen many Places even i searched a lot before using it that is there any example for PHP to retrieve the data using API here are few examples i am posting but few things needed:
- Make Sure you have the API Key which you can get by going in Settings>Channels
- Apply for the API Client in the API section clicking "Add API client" button fill the form and it will generate a API Key and some other useful information
- Now Open your PHP File Lets say you want to get all the articles on your Website using API then you can use following code:
$r = new HttpRequest('https://YOUR_DOMAIN_NAME/api/v1/articles.json', HttpRequest::METHGET);
$r->addQueryData(array('client' => 'INSERTYOURAPIKEY_HERE'));
try {
$r->send();
if ($r->getResponseCode() == 200) {
$obj=json_decode($r->getResponseBody());
print_r($obj);
}
}
catch (HttpException $ex) {
echo $ex;
}
Make Sure you Put Relevant Info Like your Domain name and API KEY to run this code
-
Anonymous commented
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui est in parvis malis. Ecce aliud simile dissimile. Qui convenit? Quorum altera prosunt, nocent altera. Duo Reges: constructio interrete.
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tu quidem reddes; Neutrum vero, inquit ille. Sed fortuna fortis; Duo Reges: constructio interrete.
-
Anonymous commented
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Invidiosum nomen est, infame, suspectum. Istam voluptatem, inquit, Epicurus ignorat? Quod cum dixissent, ille contra. Etiam beatissimum? Duo Reges: constructio interrete. Sed quid sentiat, non videtis.