PHP Classes

Desk.com oAuth access?

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Desk.com oAuth access?  >  (Un) Subscribe thread alerts  
Subject:Desk.com oAuth access?
Summary:Trying to access Desk.com and having problems
Messages:4
Author:Bane Zaklan
Date:2012-10-11 08:50:45
Update:2012-10-11 09:23:42
 

  1. Desk.com oAuth access?   Reply   Report abuse  
Picture of Bane Zaklan Bane Zaklan - 2012-10-11 08:50:45
Hello Manuel, thanks for the class, you're making me look good!!! :-)

I'm trying to access desk.com API using your oAuth class and having some problems.

Here is Desk.com oAuth explanation:
dev.desk.com/docs/api/oauth

Here is the code I used:
$client = new OAuth_client_class;

$client->debug = true;

$client->oauth_version = "1.0";
$client->client_id = 'XXXXXXXXX';
$client->client_secret = 'XXXXXXXXXXXXXXXXXXX';
$client->access_token = 'XXXXXXXXXXXXX';
$client->access_token_secret = 'XXXXXXXXXXXXXXXXXXXXXX';

$client->access_token_url = "https://colwiz.desk.com/oauth/access_token";
$client->request_token_url = "https://colwiz.desk.com/oauth/request_token";
$client->dialog_url = "https://colwiz.desk.com/oauth/authorize";
//$client->

$url = 'https://colwiz.desk.com/api/v1/topics.json?page=3';
$method = 'GET';
$parameters = array();
$options = array();

if( ($success = $client->Initialize()) ){
echo "Initialized!<br/>";
$success = $client->CallAPI($url, $method, $parameters, $options, $response);

if ($client->access_token_error!="") {
echo "<br>".$client->access_token_error."<br>";
}

}else{
echo "Problems in Initialization!<br/>";
}

Please take a look if I'm doing it the right way.
Thanks in advance for your help!
Regards,
Bane Zaklan



  2. Re: Desk.com oAuth access?   Reply   Report abuse  
Picture of Bane Zaklan Bane Zaklan - 2012-10-11 08:53:15 - In reply to message 1 from Bane Zaklan
One thing I forgot, the reply I am getting:

array(1) {
["Invalid_OAuth_Request"]=>
string(0) ""
}

Debug output is:

"OAuth client: Accessing the API call at https://colwiz.desk.com/api/v1/topics.json?page=3 OAuth client: Could not retrieve the OAuth access. Error: it was not possible to access the API call: it was returned an unexpected response status 401 Response: Invalid OAuth Request "

  3. Re: Desk.com oAuth access?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-10-11 09:14:50 - In reply to message 1 from Bane Zaklan
I think the problem is that you are passing parameters in the URL.

Try removing the ?page=3 from the API call URL and put those values in the parameters array('page'=>'3') .

  4. Re: Desk.com oAuth access?   Reply   Report abuse  
Picture of Bane Zaklan Bane Zaklan - 2012-10-11 09:23:42 - In reply to message 3 from Manuel Lemos
Yessss....that was it!
Thanks again!