Can anyone please give a Simple Example of UserVoice API call in PHP that retrieve something (could be anything like article etc etc) because i am unable to find any Example that is doing something like that...!!
Asked
Active
Viewed 244 times
1 Answers
0
I have seen at many Places even i searched a lot before using it that is there any example for PHP to retrieve the data using UserVoice API but unable to find so after lots of things i found solution myself here is an example 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::METH_GET); $r->addQueryData(array('client' => 'INSERT_YOUR_API_KEY_HERE')); try { $r->send(); if ($r->getResponseCode() == 200) { $obj=json_decode($r->getResponseBody()); print_r($obj); } } catch (HttpException $ex) { echo $ex; }

Seeker
- 1,877
- 4
- 32
- 56