Reputation: 77
I'm working a Facebook login functionality which works smoothly, however I tried to Google this but couldn't find anything that I was looking for.
I need to get user profile pictures, interests, likes, books, movies, music. Code below is my controller which works fine.
class Welcome extends CI_Controller {
public function __construct() { parent::__construct();
} public function index() {
$fb_config = array( 'appId' => '550765875685678567', 'secret' => 'e03771716c87658765843535ac38' ); $this->load->library('facebook', $fb_config); $user = $this->facebook->getUser(); if ($user) { try { $data['user_profile'] = $this->facebook->api('/me'); } catch (FacebookApiException $e) { $user = null; } } if ($user) { $data['logout_url'] = $this->facebook ->getLogoutUrl(); } else { $data['login_url'] = $this->facebook ->getLoginUrl($params = array('scope' => "email,user_birthday,
user_likes, >user_interests, user_location, read_friendlists, user_checkins, user_religion_politics, user_photos, user_likes, user_hometown, user_about_me")); }
$this->load->view('welcome',$data); }
}
Now if I wanted to run
$albums = $facebook->api('/me/albums');
in same function, how would I achieve this? or how can I run multiple api calls here and include it in my $data['user_profile']?
Thanks all
Upvotes: 0
Views: 153
Reputation: 34
You can run as many API calls as you would like in sequential order and have them go into your data array. For example:
$data['user_profile'] = $this->facebook->api('/me');
$data['user_albums'] = $this->facebook->api('/me/albums');
Multiple calls won't cause any problems.
Upvotes: 0