Skip to content

Instantly share code, notes, and snippets.

@JCBarry
Created July 28, 2011 17:43
Show Gist options
  • Select an option

  • Save JCBarry/1112079 to your computer and use it in GitHub Desktop.

Select an option

Save JCBarry/1112079 to your computer and use it in GitHub Desktop.
TradeKing API PHP OAuth Example
<?php
// This is using the PHP OAuth extenstion.
// http://www.php.net/manual/en/book.oauth.php
$consumer_key = '0cc175b9c0f1b6a831c399e269772661';
$consumer_secret = 'ff2513194e75315625628304c9eb66e8';
$access_token = '150a96573adf12b21dab621e85497e6e';
$access_secret = '5c7b57d450a71d378a5eda991f809e56';
try {
$oauth = new OAuth($consumer_key,$consumer_secret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setToken($access_token,$access_secret);
$oauth->fetch("https://api.tradeking.com/v1/member/profile.json");
$response_info = $oauth->getLastResponseInfo();
// header("Content-Type: {$response_info["content_type"]}");
echo $oauth->getLastResponse();
} catch(OAuthException $E) {
echo "Exception caught!\n";
echo "Response: ". $E->lastResponse . "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment