From: Zach Copley Date: Fri, 8 Oct 2010 01:41:34 +0000 (-0700) Subject: Rename OAuth token credential fetching script X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=46de847ce0b72a85b96fcbea94624db98c265d45;p=quix0rs-gnu-social.git Rename OAuth token credential fetching script --- diff --git a/tests/oauth/exchangetokens.php b/tests/oauth/exchangetokens.php deleted file mode 100755 index 049c0cad07..0000000000 --- a/tests/oauth/exchangetokens.php +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env php -. - */ - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); - -require_once INSTALLDIR . '/extlib/OAuth.php'; - -$ini = parse_ini_file("oauth.ini"); - -// Check to make sure we have everything we need from the ini file -foreach(array('consumer_key', 'consumer_secret', 'apiroot', 'access_token_url') as $inikey) { - if (empty($ini[$inikey])) { - print "You forgot to specify a $inikey in your oauth.ini file.\n"; - exit(1); - } -} - -$consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']); - -$endpoint = $ini['apiroot'] . $ini['access_token_url']; - -$shortoptions = 't:s:v:'; -$longoptions = array('oauth_token=', 'oauth_token_secret=', 'oauth_verifier='); - -$helptext = <<sign_request($hmac_method, $consumer, $rtok); - - $httpReq = httpRequest($endpoint, $oauthReq->to_postdata()); - $body = $httpReq->getBody(); - -} catch (Exception $e) { - // oh noez - print $e->getMessage(); - print "\nOAuth Request:\n"; - var_dump($oauthReq); - exit(1); -} - -$tokenStuff = array(); -parse_str($body, $tokenStuff); - -if (empty($tokenStuff['oauth_token']) || empty($tokenStuff['oauth_token_secret'])) { - print "Error! HTTP response body: $body\n"; - exit(1); -} - -print "Access Token\n"; -print ' - oauth_token = ' . $tokenStuff['oauth_token'] . "\n"; -print ' - oauth_token_secret = ' . $tokenStuff['oauth_token_secret'] . "\n"; - -function httpRequest($endpoint, $poststr) -{ - $request = HTTPClient::start(); - - $request->setConfig( - array( - 'follow_redirects' => true, - 'connect_timeout' => 120, - 'timeout' => 120, - 'ssl_verify_peer' => false, - 'ssl_verify_host' => false - ) - ); - - parse_str($poststr, $postdata); - return $request->post($endpoint, null, $postdata); -} - diff --git a/tests/oauth/fetch_token_creds.php b/tests/oauth/fetch_token_creds.php new file mode 100755 index 0000000000..a508c7240c --- /dev/null +++ b/tests/oauth/fetch_token_creds.php @@ -0,0 +1,146 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); + +require_once INSTALLDIR . '/extlib/OAuth.php'; + +$ini = parse_ini_file("oauth.ini"); + +// Check to make sure we have everything we need from the ini file +foreach(array('consumer_key', 'consumer_secret', 'apiroot', 'access_token_url') as $inikey) { + if (empty($ini[$inikey])) { + print "You forgot to specify a $inikey in your oauth.ini file.\n"; + exit(1); + } +} + +$consumer = new OAuthConsumer($ini['consumer_key'], $ini['consumer_secret']); + +$endpoint = $ini['apiroot'] . $ini['access_token_url']; + +$shortoptions = 't:s:v:'; +$longoptions = array('oauth_token=', 'oauth_token_secret=', 'oauth_verifier='); + +$helptext = <<sign_request($hmac_method, $consumer, $rtok); + + $httpReq = httpRequest($endpoint, $oauthReq->to_postdata()); + $body = $httpReq->getBody(); + +} catch (Exception $e) { + // oh noez + print $e->getMessage(); + print "\nOAuth Request:\n"; + var_dump($oauthReq); + exit(1); +} + +$tokenStuff = array(); +parse_str($body, $tokenStuff); + +if (empty($tokenStuff['oauth_token']) || empty($tokenStuff['oauth_token_secret'])) { + print "Error! HTTP response body: $body\n"; + exit(1); +} + +print "Access Token\n"; +print ' - oauth_token = ' . $tokenStuff['oauth_token'] . "\n"; +print ' - oauth_token_secret = ' . $tokenStuff['oauth_token_secret'] . "\n"; + +function httpRequest($endpoint, $poststr) +{ + $request = HTTPClient::start(); + + $request->setConfig( + array( + 'follow_redirects' => true, + 'connect_timeout' => 120, + 'timeout' => 120, + 'ssl_verify_peer' => false, + 'ssl_verify_host' => false + ) + ); + + parse_str($poststr, $postdata); + return $request->post($endpoint, null, $postdata); +} +