Search code examples
phpapitumblruser-defined-functionstemboo

Function does not seem to work correctly after modification


I am trying to make this work but, I need help on this function. It works great but after I modifed it to show user dashboard with choreos from Temboo i get no results. The two functions are in different php files namely index.php and dashboard.php . Please show me where I could be having errors. Thank you

Main source :https://raw.github.com/matthewflaming/temboo-experiments/master/TumblrOauth/tumblrOauth.php

My dashboard.php : https://tumblr-app-c9-c9-paulkinobunga.c9.io/dashboard.php

Too see my index.php file replace dahboard.php with index.php

The Function

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;
}

To get response I simply say:

Raw response returned by Tumblr:

<?php

// Get current user info for Tumblr
$currentUserResults = getUserInfo($session);

print_r($currentUserResults);
?>

THE MODIFIED FUNCTION

function getUserDash($session) {

global $AccessToken, $AccessTokenSecret;

// Instantiate the Choreo, using a previously instantiated Temboo_Session object, eg:
$getUserDashboard = new Tumblr_User_GetUserDashboard($session);

// Get an input object for the Choreo
$getUserDashboardInputs = $getUserDashboard->newInputs();

// Set inputs
   $getUserDashboardInputs->setAPIKey(TUMBLR_CONSUMER_KEY)->setAccessToken($AccessToken)->setAccessTokenSecret($AccessTokenSecret)->setSecretKey(TUMBLR_CONSUMER_SECRET);

// Execute Choreo and get results
$getUserDashboardResults = $getUserDashboard->execute($getUserDashboardInputs)->getResults();

return $getUserDashboardResults;
}

To get response I say

 //Raw response returned by Tumblr:<br>
<?php

            // Get current user info for Tumblr
            $currentUserResults = getUserDash($session);

            print_r($currentUserResults);
        ?>

The two functions are in different php files namely index.php and dashboard.php . Please show me where I could be having errors.


Solution

  • The problem here is that the Temboo Choreography is incorrectly referenced in the sample "getUserDash" function you've provided.

    Rather than "Tumblr_User_GetUserDashboard" the name of the object should be "Tumblr_User_RetrieveUserDashboard" -- so the code should look like:

    function getUserDash($session) {
    
       global $AccessToken, $AccessTokenSecret;
    
       $getUserDashboard = new Tumblr_User_RetrieveUserDashboard($session);
    
       $getUserDashboardInputs = $getUserDashboard->newInputs();
    
       $getUserDashboardInputs->setAPIKey(TUMBLR_CONSUMER_KEY)->setAccessToken($AccessToken)->setAccessTokenSecret($AccessTokenSecret)->setSecretKey(TUMBLR_CONSUMER_SECRET);
    
       // Execute Choreo and get results 
       $getUserDashboardResults = $getUserDashboard->execute($getUserDashboardInputs)->getResults();
    
       return $getUserDashboardResults; 
    }