Skip to content

Instantly share code, notes, and snippets.

@pau1m
Created February 13, 2013 12:34
Show Gist options
  • Save pau1m/4944280 to your computer and use it in GitHub Desktop.
Save pau1m/4944280 to your computer and use it in GitHub Desktop.
Quick n dirty oauth request
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
//@see http://oauth.googlecode.com/svn/code/php/
require "lib/OAuth.php";
$key = 'xx';
$secret = 'xx';
$consumer = new OAuthConsumer($key, $secret);
$url = 'http://example.com/endpoint/resource';
$req = OAuthRequest::from_consumer_and_token($consumer, null, "GET", $url, null);
$sig_method = new OAuthSignatureMethod_HMAC_SHA1();
$req->sign_request($sig_method, $consumer, null);
$ch = curl_init($req->to_url());
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Accept: application/json'));
header('Content-type: application/json');
curl_exec($ch);
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment