Beispiel #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');
Beispiel #2
0
	#
	# next we update
	#

	$ret2 = oauth_request($keys, 'http://api.twitter.com/1/account/update_profile.json', array(
		'url' => $test_url,
	), 'POST');
	if (!strlen($ret2)) dump_last_request();

	$obj = json_decode($ret2, 1);
	$new_url = $obj[url];

	echo "changed to $new_url<br />";


	#
	# now update again
	#

	$ret3 = oauth_request($keys, 'http://api.twitter.com/1/account/update_profile.json', array(
		'url' => $orig_url,
	), 'POST');
	if (!strlen($ret3)) dump_last_request();

	$obj = json_decode($ret3, 1);
	$final_url = $obj[url];

	echo "changed back to $final_url<br />";

?>