Search code examples
phpoauthuservoice

UserVoice's OAuth Implementation in PHP


I am able to get the Records of the UserVoice by calling and Unauthorized Requests but now i want to create and Update things in which i need OAuth but i am unable to find the UserVoice's PHP Implementation of OAuth and Create/Update/Delete with UserVoice API is there anyone can guide me how to Implement such thing??


Solution

  • We have quite recently worked on this and released an OAuth-based library which makes it a bit easier to access UserVoice API from a PHP version 5 application.

    An example on how to create a ticket using an access token for [email protected]:

    <?php
        require_once('vendor/autoload.php'); // Using Composer
    
        $client = new \UserVoice\Client('subdomain-name', 'API KEY', 'API SECRET');
        $access_token = $client->login_as('[email protected]');
    
        $result = $access_token->post("/api/v1/tickets", array(
                'ticket' => array(
                    'state' => 'open',
                    'subject' => 'PHP SDK',
                    'message' => "Would you have any OAuth example for PHP?"
                )
        ));
    ?>
    

    Despite the fact that the library is still under development, I believe it's already useful to you. See the blog post and more examples like responding to tickets as an account owner at:

    http://developer.uservoice.com/docs/api/php-sdk/