#!/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); }