Skip to content

Instantly share code, notes, and snippets.

@tyler-smith
Created November 5, 2012 19:09
Show Gist options
  • Save tyler-smith/4019659 to your computer and use it in GitHub Desktop.
Save tyler-smith/4019659 to your computer and use it in GitHub Desktop.
Set UserVoice Suggestion's vote with PHP API
<?php
$USERVOICE_SUBDOMAIN = '**SCRUBED**';
$SSO_KEY = '**SCRUBED**';
$API_KEY = '**SCRUBED**';
$API_SECRET = '**SCRUBED**';
// Use autoload.php of Composer to use the library and its dependencies:
require_once 'vendor/autoload.php';
$user = '**SCRUBED**';
$forum_id = 1;
$suggestion_id = 1;
$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) {
echo "<pre>";
var_dump($e);
echo "</pre>";
} catch (\UserVoice\NotFound $e) {
echo "<pre>";
var_dump($e);
echo "</pre>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment