Example #1
0
/**
 * Returns the access token to use in twitter calls.
 *
 * @param bool $oauth_verifier
 * @return array
 */
function twitter_api_get_access_token($oauth_verifier = FALSE)
{
    /* @var ElggSession $SESSION */
    global $SESSION;
    // retrieve stored tokens
    $oauth_token = $SESSION['twitter_api']['oauth_token'];
    $oauth_token_secret = $SESSION['twitter_api']['oauth_token_secret'];
    unset($SESSION['twitter_api']);
    // fetch an access token
    $api = twitter_api_get_api_object($oauth_token, $oauth_token_secret);
    return $api->getAccessToken($oauth_verifier);
}
/**
 * Returns the access token to use in twitter calls.
 *
 * @param bool $oauth_verifier
 * @return array
 */
function twitter_api_get_access_token($oauth_verifier = FALSE)
{
    $session = elgg_get_session();
    // retrieve stored tokens
    $api_settings = $session->get('twitter_api');
    $oauth_token = $api_settings['oauth_token'];
    $oauth_token_secret = $api_settings['oauth_token_secret'];
    $session->remove('twitter_api');
    // fetch an access token
    $api = twitter_api_get_api_object($oauth_token, $oauth_token_secret);
    return $api->getAccessToken($oauth_verifier);
}
Example #3
0
/**
 * Get tweets for a user.
 *
 * @param int   $user_guid The Elgg user GUID
 * @param array $options
 * @return array
 */
function twitter_api_fetch_tweets($user_guid, $options = array())
{
    // check user settings
    $access_key = elgg_get_plugin_user_setting('access_key', $user_guid, 'twitter_api');
    $access_secret = elgg_get_plugin_user_setting('access_secret', $user_guid, 'twitter_api');
    if (!($access_key && $access_secret)) {
        return FALSE;
    }
    $api = twitter_api_get_api_object($access_key, $access_secret);
    if (!$api) {
        return FALSE;
    }
    return $api->get('statuses/user_timeline', $options);
}