Created
November 1, 2012 19:16
-
-
Save tyler-smith/3995802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// 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