Search code examples
drupal-7hybridauth

How to load other users Twitter wall using Hybridauth


I am using this code right now to pull a users

$hybridauth = new Hybrid_Auth( $config ); 
$hybridauth_session_data = get_stored_hybridauth_session( $current_user_id );
$hybridauth->restoreSessionData( $hybridauth_session_data );
$twitter = $hybridauth->getAdapter( "Twitter" ); 
$user_profile = $twitter->getUserProfile(); 

And it works fine for the current logged in user.

Now i want to show other users Twitter wall on a new page when this user is visiting the other user. Is that possible?


Solution

  • Use restoreSessionData to store other users session data that you should save to DB, and use the following method

     $hybridauth->restoreSessionData( OTHER-USER-SESSION-DATA);
     $twitter = $hybridauth->authenticate( "Twitter" );
     $twitter_timeline = $twitter->api()->api('statuses/user_timeline.json?count=20&trim_user=TRUE');     
     $dataFilteredTwit = _hitsup_filter_timeline($twitter_timeline, "Twitter" );