Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 61 lines (52 sloc) 1.682 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<?php

require_once 'lib/2leggedOAuthRequestGenerator.php';

$api_url = 'http://r-weblife.sakura.ne.jp/SignedRequest/example.php';
$opensocial_appurl = 'http://r-weblife.sakura.ne.jp/SignedRequest/SignedRequest.xml';

$consumerkey = 'r-weblife.sakura.ne.jp';
$consumersecret = 'r-weblife.sakura.ne.jp.secret';

$params = array(
    "opensocial_app_url" => $opensocial_appurl,
    "opensocial_param_a" => "testValueA",
    "opensocial_param_b" => "testValueB"
);

$ur = "";
$response = "";
$generator = new twoLeggedOAuthRequestGenerator( $api_url, $consumerkey, $consumersecret, 'HMAC-SHA1', 'GET', $params );

if( $generator ){
$url = $generator->getUrl();
$response = getResponse( $url );
}else{
print "sorry...";
exit;
}

function getResponse($url, $post_data = null) {
  $ch = curl_init();
  if (defined("CURL_CA_BUNDLE_PATH")) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  if (isset($post_data)) {
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  }
  $response = curl_exec($ch);
  curl_close ($ch);
  return $response;
}

?>
<html>
<body>
<h2>2legged OAuth Test (HMAC-SHA1 Signature) </h2>
<p>request :</p>
<?php print nl2br( str_replace( "&", "\n&", $url ) ); ?>
<br />
<p>response : </p>
<pre>
<?php print $response; ?>
</pre>
<p><a href="./2leggedOAuthRequestGeneratorTest_RSA.php">RSA-SHA1</a></p>
<p><a href="./2leggedOAuthRequestGeneratorTest_HMAC.php">HMAC-SHA1</a></p>
</body>
</html>
Something went wrong with that request. Please try again.