0

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

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, appreciate your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.