Hi BJ, Here is the complete code:
include_once "oauth-php/library/OAuthStore.php"; include_once "oauth-php/library/OAuthRequester.php"; // register at http://twitter.com/oauth_clients and fill these two define("TWITTER_CONSUMER_KEY", ""); // I removed this for this post define("TWITTER_CONSUMER_SECRET", ""); // I removed this for this post define("TWITTER_OAUTH_HOST","http://api.twitter.com"); define("TWITTER_REQUEST_TOKEN_URL", TWITTER_OAUTH_HOST . "/oauth/ request_token"); define("TWITTER_AUTHORIZE_URL", TWITTER_OAUTH_HOST . "/oauth/ authorize"); define("TWITTER_ACCESS_TOKEN_URL", TWITTER_OAUTH_HOST . "/oauth/ access_token"); define("TWITTER_PUBLIC_TIMELINE_API", TWITTER_OAUTH_HOST . "/statuses/ public_timeline.json"); define("TWITTER_UPDATE_STATUS_API", TWITTER_OAUTH_HOST . "/1/statuses/ update.json"); define('OAUTH_TMP_DIR', function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : realpath($_ENV["TMP"])); // Twitter test $options = array('consumer_key' => TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET); OAuthStore::instance("2Leg", $options); try { // Obtain a request object for the request we want to make $request = new OAuthRequester(TWITTER_REQUEST_TOKEN_URL, "POST"); $result = $request->doRequest(0); parse_str($result['body'], $params); // now make the request. $request = new OAuthRequester(TWITTER_PUBLIC_TIMELINE_API, 'GET', $params); $result = $request->doRequest(); $request = new OAuthRequester(TWITTER_UPDATE_STATUS_API, 'POST', array('status' => 'Test')); $result = $request->doRequest(); } catch(OAuthException2 $e) { echo "Exception: " . $e->getMessage() . "\n"; } ?> On Sep 28, 6:16 pm, BJ Weschke <[email protected]> wrote: > Are you certain that you're using the access token and secret received > and not the request token and secret? > > Rajendra Singh wrote: > > Help anyone? > > > On Sep 6, 7:16 pm, Rajendra Singh <[email protected]> wrote: > > >> Hi Tom, > > >> Yes I did fill in those values correctly. > > >> On Sep 6, 5:44 pm, Tom van der Woerdt <[email protected]> wrote: > > >>> On 9/6/10 10:57 PM, Rajendra Singh wrote: > > >>>> Hello, > > >>>> I took the "twoleggedtwitter.php" example file and added the following > >>>> two lines: > > >>>> $request = new OAuthRequester(TWITTER_UPDATE_STATUS_API, 'POST', > >>>> "status=Test"); > >>>> $result = $request->doRequest(); > > >>>> However, when I execute it, I get: > >>>> Exception: Request failed with code401: {"request":"/statuses/ > >>>> update.json","error":"Invalid/expiredToken"} > > >>>> Can someone help me? What am I doing wrong? > > >>> Did you fill in the consumertokenand secret? And the usertokenand > >>> secret? > > >>> Tom -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk
