newInputs(); // Set inputs $initializeOAuthInputs->setAPIKey(TUMBLR_CONSUMER_KEY); $initializeOAuthInputs->setSecretKey(TUMBLR_CONSUMER_SECRET); // Specify the forwarding URL, to which users should be sent after clicking "allow" // In this case, we simply direct the user back to this page. $initializeOAuthInputs->setForwardingURL(PAGE_LOCATION . "?finalize=true"); // Execute Choreo and get results $initializeOAuthResults = $initializeOAuth->execute($initializeOAuthInputs)->getResults(); // Store the retrieved callback ID and token secret in a cookie setcookie("TembooCallbackID", $initializeOAuthResults->getCallbackID(), time()+300); setcookie("OAuthTokenSecret", $initializeOAuthResults->getOAuthTokenSecret(), time()+300); // Set the global authorization URL, to which we'll redirect the user global $authorizationURL; $authorizationURL = $initializeOAuthResults->getAuthorizationURL(); } // Finalize the Tumblr oAuth process, by retrieving callback data and exchanging it // for an oAuth Token and Token Secret function finalizeOAuth($session, $callbackID, $OAuthTokenSecret) { // Instantiate the Choreo, using a previously instantiated Temboo_Session object, eg: $finalizeOAuth = new Tumblr_OAuth_FinalizeOAuth($session); // Get an input object for the Choreo $finalizeOAuthInputs = $finalizeOAuth->newInputs(); // Set inputs $finalizeOAuthInputs->setCallbackID($callbackID); $finalizeOAuthInputs->setAPIKey(TUMBLR_CONSUMER_KEY); $finalizeOAuthInputs->setSecretKey(TUMBLR_CONSUMER_SECRET); $finalizeOAuthInputs->setOAuthTokenSecret($OAuthTokenSecret); // Execute Choreo and get results $finalizeOAuthResults = $finalizeOAuth->execute($finalizeOAuthInputs)->getResults(); // set the global oAuth token and token secret global $AccessToken, $AccessTokenSecret; $AccessToken = $finalizeOAuthResults->getAccessToken(); $AccessTokenSecret = $finalizeOAuthResults->getAccessTokenSecret(); // Store the OAuth token and secret in a cookie setcookie("TumblrAccessToken", $AccessToken, time()+600); setcookie("TumblrAccessTokenSecret", $AccessTokenSecret, time()+600); } // Get the user's information from Tumblr function getUserInfo($session) { global $AccessToken, $AccessTokenSecret; // Instantiate the Choreo, using a previously instantiated Temboo_Session object, eg: $getUserInformation = new Tumblr_User_GetUserInformation($session); // Get an input object for the Choreo $getUserInformationInputs = $getUserInformation->newInputs(); // Set inputs $getUserInformationInputs->setAPIKey(TUMBLR_CONSUMER_KEY)->setAccessToken($AccessToken)->setAccessTokenSecret($AccessTokenSecret)->setSecretKey(TUMBLR_CONSUMER_SECRET); // Execute Choreo and get results $getUserInformationResults = $getUserInformation->execute($getUserInformationInputs)->getResults(); return $getUserInformationResults; } ?> This is a simple demonstration of doing oAuth authentication with the Tumblr API, using the Temboo SDK. To authenticate with Tumblr, click here. Successfully authenticated via oAuth with Tumblr! Your oAuth access token value is:
Now, let's load your Tumblr user information:
Raw response returned by Tumblr: