<?php include_once "oauth-php-98/library/OAuthStore.php"; include_once "oauth-php-98/library/OAuthRequester.php"; include_once 'config.php'; // Create a new session object. It will flush any local cookies that you have in case // you hit this page in error, since this should be the "Login" page. $user_session = new TPSession(); // Obtain a Request token from TypePad. $user_session->request_and_verify_request_token(); // Next step in the OAuth Dance: Redirect your user to the Provider. // this redirect() method is courtesy of our OAuthPHP lib. Parameters: // 1 = the URL to redirect to // 2 = a list of parameters. In our case, it's the Request token. /* * 'oauth-authorization-page' is deprecated in favor of 'oauthAuthorizationUrl'. OAuthRequest::redirect($user_session->get_api_endpoint('oauth-authorization-page'), array('oauth_token' => $user_session->oauth_token)); */ OAuthRequest::redirect($user_session->get_api_endpoint(TP_OAUTH_AUTH_URL), array('oauth_token' => $user_session->oauth_token)); // FYI: HTML is forbidden in this file, since the redirect's headers cannot be written!! ?>
oauth_signature=n3lQROBcPnBZvEgplUzHcgkUCrA%3D & oauth_timestamp=1269811986 & oauth_callback=http%3A%2F%2F127.0.0.1%3A5000%2Flogin-callback & oauth_nonce=853433351 & oauth_consumer_key=c5139cef2985b86d & oauth_version=1.0 & oauth_signature_method=HMAC-SHA1 */ $handle = fopen($final_url, "rb"); $doc = stream_get_contents($handle); $response_array = explode("&", $doc); // Store the results! Anything but 200 will croak to the browser for now. $response = array(); foreach ($response_array as $response_str) { $pair = explode("=", $response_str); $response[$pair[0]] = $pair[1]; } // Instead of storing the Request token as a cookie, write it to the db. $store->addServerToken(CONSUMER_KEY, 'request', $response['oauth_token'], $response['oauth_token_secret'], $user_id, ''); var_dump($oauth); debug("After creating a simple request token, store obj = ^ "); /* Next step in the OAuth Dance: Redirect your user to the Provider. */ $query_params = array(); $query_params['oauth_token'] = $response['oauth_token']; // the redirect() method is from the OAuth library OAuthRequest::redirect($endpoint_strs['oauth-authorization-page'], $query_params); // HTML is forbidden in this file, since the redirect's headers cannot be written!! ?>