示例#1
0
<?php

include 'lib_oauth.php';
include 'config.php';
$keys = array('oauth_key' => OAUTH_CONSUMER_KEY, 'oauth_secret' => OAUTH_CONSUMER_SECRET, 'request_key' => $_COOKIE[my_req_key], 'request_secret' => $_COOKIE[my_req_secret]);
##########################################################################################
#
# STEP 2 - exchange the authorized access token for a request token
#
$params = array();
# OAuth 1.0a servers will return an extra oauth_verifier argument
if (isset($_GET[oauth_verifier])) {
    $params[oauth_verifier] = $_GET[oauth_verifier];
}
$ok = oauth_get_access_token($keys, OAUTH_ACCESS_URL, $params);
if (!$ok) {
    echo "Something didn't work!<hr />";
    dump_last_request();
    exit;
}
setcookie('my_acc_key', $keys[user_key]);
setcookie('my_acc_secret', $keys[user_secret]);
header('location: geo.html');
示例#2
0
		echo "access url is $url\n";
		exit;
	}else{
		die("something went wrong");
	}

	# (this step adds two keys to the $keys hash)


	##########################################################################################
	#
	# STEP 2 - exchange the authorized access token for a request token
	#

	$ok = oauth_get_access_token($keys, 'http://example.com/access-token-url');

	if ($ok){

		echo "it worked!";
		exit;
	}else{
		die("it didn't work!");
	}
	
	# (this step adds two more keys to the $keys hash)


	##########################################################################################
	#
	# STEP 3 - access the protected resource