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 8995269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:35:50+00:00 2026-06-15T23:35:50+00:00

I’ve made a Facebook app which works perfectly, so now I’m trying to setup

  • 0

I’ve made a Facebook app which works perfectly, so now I’m trying to setup a mobile app. I use this code with is described in the docs to check if the user is logged in or not, and if the user is logged in pass the information forward.

Here is the code I’m using:

<?php 
session_start();

// Include facebook PHP SDK
 require_once("lib/facebook.php");
 

// Configure the facebook object
$config = array();
$config['appId'] = 'APP_ID';
$config['secret'] = 'APP_SECRET';
$config['cookie'] = true;
$config['fileUpload'] = true;

$app_id = 'APP_ID';
$canvas_page = "https://hadadmin.yourwebhosting.com/mixit/mobile/";

     $location = "https://www.facebook.com/dialog/oauth?client_id=" 
        . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=publish_stream,email,create_event,rsvp_event,user_events,friends_events";

    // initialize the facebook oject
  $facebook = new Facebook($config);

    // Get Facebook User
    $fbID = $facebook->getUser();
 
    // Get the current access token
    $access_token = $facebook->getAccessToken();
    
    // check if we have valid user
if ($fbID) {
    try {
        // Proceed knowing you have a logged in user who's authenticated.
        $fb_user_profile = $facebook->api('/me');   

    } catch (FacebookApiException $e) {
        $fbID = NULL;
        // seems we don't have enough permissions
        // we use javascript to redirect user instead of header() due to Facebook bug
        print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';

        // kill the code so nothing else will happen before user gives us permissions
        die();
    } 

} else {
    // seems our user hasn't logged in, redirect him to a FB login page

print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';

  // kill the code so nothing else will happen before user gives us permissions
   die();
}

I’ve searched all over but none of the solutions to similar problems are working (i.e. getUser returns 0) getUser is returning 0 like in the other posts, but like I said it works fine when I don’t use the mobile site, apps.facebook.com/MYAPP and https://hadadmin.yourwebhosting.com/mixit/ is also working.

  • 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-06-15T23:35:51+00:00Added an answer on June 15, 2026 at 11:35 pm

    getUser use cookie setup by the javascript SDK or via the signed_request (for canvas and page tab).

    As you’re on a mobile site and if it’s the first user connection, you’ll have no cookie, and obvisously no signed_request. So you need to setup the Facebook connection using the javascript SDK by settings status to true in the init method, or by calling getLoginStatus. Then, you can request your server (the cookie will be send with any ajax request on the same domain).

    after edit:
    From what I see, you have trouble with cross-domain communication here. Be sure to setup facebook correctly with a valid channel file. For IE, setup P3P headers, that will help a lot. For Safari, that’s a hell of a job, but google “cross-domain communication” and you’ll find a lot of solutions. But these shouldn’t be necessary if Facebook SDKs are setup correctly.

    Hope this help!

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.