Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:30:06+00:00 2026-05-22T17:30:06+00:00

I am trying to work out facebook connect based on this tutorial: http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/ They

  • 0

I am trying to work out facebook connect based on this tutorial:
http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/

They have given you a few scripts to use to figure it out, this is the extended permissions one:

<?php
# We require the library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
 'appId'  => '...',
 'secret' => '...',
 'cookie' => true
));

# Let's see if we have an active session
$session = $facebook->getSession();

if(!empty($session)) {
 # Active session, let's try getting the user id (getUser()) and user info (api->('/me'))
 try{
  $uid = $facebook->getUser();

  # req_perms is a comma separated list of the permissions needed
  $url = $facebook->getLoginUrl(array(
   'req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'
  ));
  header("Location: {$url} ");
 } catch (Exception $e){}
} else {
 # There's no active session, let's generate one
 $login_url = $facebook->getLoginUrl();
 header("Location: ".$login_url);
}

When I execute this it lets me allow the extended permissions but then I get a redirect loop error. When I check in facebook it has granted extended permissions.

Now I tried to just implement it into the login script they gave, which is this

# We require the library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
 'appId'  => '...',
 'secret' => '...',
 'cookie' => true
));

# Let's see if we have an active session
$session = $facebook->getSession();

if(!empty($session)) {
 # Active session, let's try getting the user id (getUser()) and user info (api->('/me'))
 try{
  $uid = $facebook->getUser();
  $user = $facebook->api('/me');

 } catch (Exception $e){}

 if(!empty($user)){
  # We have an active session, let's check if we have already registered the user
  $query = mysql_query("SELECT * FROM users WHERE oauth_prov = 1 AND oauth_id = ". $user['id']);
  $result = mysql_fetch_array($query);

  # If not, let's add it to the database

  echo $user['id'] . $user['name'];

  if(empty($result)){
   $query = mysql_query("INSERT INTO users (oauth_prov, oauth_id, username) VALUES ('1', {$user['id']}, '{$user['name']}')");
   $query = mysql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());
   $result = mysql_fetch_array($query);
  }

  // this sets variables in the session 
  $_SESSION['id'] = $result['id'];
  $_SESSION['oauth_uid'] = $result['oauth_id'];
  $_SESSION['oauth_provider'] = $result['oauth_provider'];
  $_SESSION['username'] = $result['username'];



 } else {
  # For testing purposes, if there was an error, let's kill the script
  die("There was an error.");
 }
} else {
 # There's no active session, let's generate one
 $login_url = $facebook->getLoginUrl();
 header("Location: ".$login_url);
}

However, I don’t know where it should go, as I would like to request permissions at the same time as the login to get the users details. If I put this:

try{
  $uid = $facebook->getUser();

  # req_perms is a comma separated list of the permissions needed
  $url = $facebook->getLoginUrl(array(
   'req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'
  ));
  header("Location: {$url} ");


 } catch (Exception $e){}

After I set the session values then I don’t even get to allow anything, it just hangs and I get a redirect error.
If I put it just after getting the facebook user_id then it gives me the allow dialog (although one after the other as its obviously asking twice, something I would like to stop) but then again gives me a redirect error, having granted the extended permissions

I really don’t have a clue where to put it, the documentation for facebook is absolutely abysmal

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:30:07+00:00Added an answer on May 22, 2026 at 5:30 pm

    Instead of this:

    # req_perms is a comma separated list of the permissions needed
    $url = $facebook->getLoginUrl(array('req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'));
    

    try:

    $url = $facebook->getLoginUrl(array('scope' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'));
    

    for an complete example see the php-sdk:
    https://github.com/facebook/php-sdk/blob/master/examples/example.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the basic information array on this page http://www.facebook.com/pages/Nichi-Vendola/38771508894?sk=info I'm using
I'm trying to work out a way of passing the web current http context
Trying to work out this whole web part personalisation, and trying to implement it
I'm trying to implement Facebook Connect on a website with .NET MVC using C#.
I'm trying to figure out if this is possible or not within a facebook
I am new to PHP and I am trying to work on this one
I'm trying out the tutorials for Facebook developers. However, I can't include the Facebook
I find my self out of ideas trying to get this app to work.
I am trying work out with MERGE statment to Insert / Update Dimension Table
I am trying to work out the best database model for the current setup:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.