Skip to content

Instantly share code, notes, and snippets.

@tyler-smith
Created November 1, 2012 19:16
Show Gist options
  • Save tyler-smith/3995802 to your computer and use it in GitHub Desktop.
Save tyler-smith/3995802 to your computer and use it in GitHub Desktop.
<?
// Your account info
$USERVOICE_SUBDOMAIN = 'your_subdomain';
$API_KEY = 'your_key';
$API_SECRET = 'your_secret';
// Info about the suggestion and user
$user = '[email protected]';
$forum_id = 1234;
$suggestion_id = 5678;
$set_votes_to = 3;
try {
$client = new \UserVoice\Client($USERVOICE_SUBDOMAIN, $API_KEY, $API_SECRET);
// Now, let's login as [email protected], a regular user
$regular_access_token = $client->login_as($user);
// Set votes to 3
$regular_access_token->post("/api/v1/forums/$forum_id/suggestions/$suggestion_id/votes.json", array(
'to' => $set_votes_to
));
} catch (\UserVoice\Unauthorized $e) {
/* Thrown usually due to faulty tokens, untrusted client or if attempting
* operations without Admin Privileges
*/
var_dump($e);
} catch (\UserVoice\NotFound $e) {
// Thrown when attempting an operation to a resource that does not exist
var_dump($e);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment