Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning a PHP script using PHP OAuth extension on remote host.
    primarykey
    data
    text
    <p>I am using the following php script in order to access Fitbit API. The problem is when I run the script in local host it works fine but when I run it on remote server, it gives the following exception:</p> <pre><code> OAuthException Object ( [message:protected] =&gt; making the request failed (dunno why) [string:Exception:private] =&gt; [code:protected] =&gt; -1 [file:protected] =&gt; /net/www/example.com/htdocs/exampleFitbit.php [line:protected] =&gt; 41 [trace:Exception:private] =&gt; Array ( [0] =&gt; Array ( [file] =&gt; /net/www/example.com/htdocs/exampleFitbit.php [line] =&gt; 41 [function] =&gt; getRequestToken [class] =&gt; OAuth [type] =&gt; -&gt; [args] =&gt; Array ( [0] =&gt; http://api.fitbit.com/oauth/request_token [1] =&gt; http://www.example.com/exampleFitbit.php ) ) ) [previous:Exception:private] =&gt; [lastResponse] =&gt; [debugInfo] =&gt; ) </code></pre> <hr> <h2><strong>The script:</strong></h2> <pre><code> &lt;?php $baseUrl = 'http://api.fitbit.com'; $req_url = $baseUrl . '/oauth/request_token'; $authurl = $baseUrl . '/oauth/authorize'; $acc_url = $baseUrl . '/oauth/access_token'; $conskey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $conssec = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $apiCall = "http://api.fitbit.com/1/user/-/profile.xml"; session_start(); if ( !isset($_GET['oauth_token']) &amp;&amp; $_SESSION['state']==1 $_SESSION['state'] = 0; try { $oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION); $oauth-&gt;enableDebug(); if ( $_SESSION['state'] == 0 ) { $request_token_info = $oauth-&gt;getRequestToken($req_url, 'http://example.com/exampleFitbit.php'); $_SESSION['secret'] = $request_token_info['oauth_token_secret']; $_SESSION['state'] = 1; header('Location: '.$authurl.'?oauth_token='.$request_token_info['oauth_token']); exit; } else if ( $_SESSION['state']==1 ) { $oauth-&gt;setToken($_GET['oauth_token'],$_SESSION['secret']); $access_token_info = $oauth-&gt;getAccessToken($acc_url); $_SESSION['state'] = 2; $_SESSION['token'] = $access_token_info['oauth_token']; $_SESSION['secret'] = $access_token_info['oauth_token_secret']; } $oauth-&gt;setToken($_SESSION['token'],$_SESSION['secret']); $oauth-&gt;fetch($apiCall); $response = $oauth-&gt;getLastResponse(); $xml = simplexml_load_string($response); print_r($xml); } catch( OAuthException $E ) { print_r($E); } ?&gt; </code></pre> <p>If there is any resource/tutorial/help/hint please share.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload