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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:26:46+00:00 2026-06-14T11:26:46+00:00

I am trying to learn facebook app development and here s the code I

  • 0

I am trying to learn facebook app development and here s the code I am trying.

<?php
require_once 'config.php';

/* Get a valid session */
$session = $facebook->getUser();
$me = null;
if($session) {
/* Check if session is valid */
$me = $facebook->api('/me');
}

var_dump($me);
?>

I have set my app id and secret in config.php but it is failing to execute getUser(), all it returns is null.

Check it here.

http://facebookdevelop.byethost8.com/index.php

Do I need special setup to be done except copying facebook php sdk in hosting site? Is there a place where up-to date information is available which clearly defines step by step instructions?

  • 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-14T11:26:47+00:00Added an answer on June 14, 2026 at 11:26 am

    This code works

    <?php
    
    /**
     * This sample app is provided to kickstart your experience using Facebook's
     * resources for developers.  This sample app provides examples of several
     * key concepts, including authentication, the Graph API, and FQL (Facebook
     * Query Language). Please visit the docs at 'developers.facebook.com/docs'
     * to learn more about the resources available to you
     */
    
    // Provides access to app specific values such as your app id and app secret.
    // Defined in 'AppInfo.php'
    require_once('AppInfo.php');
    
    // Enforce https on production
    if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
      header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
      exit();
    }
    
    // This provides access to helper functions defined in 'utils.php'
    require_once('utils.php');
    
    
    /*****************************************************************************
     *
     * The content below provides examples of how to fetch Facebook data using the
     * Graph API and FQL.  It uses the helper functions defined in 'utils.php' to
     * do so.  You should change this section so that it prepares all of the
     * information that you want to display to the user.
     *
     ****************************************************************************/
    
    require_once('sdk/src/facebook.php');
    
    $facebook = new Facebook(array(
      'appId'  => AppInfo::appID(),
      'secret' => AppInfo::appSecret(),
      'sharedSession' => true,
      'trustForwarded' => true,
    ));
    
    $user_id = $facebook->getUser();
    if ($user_id) {
      try {
        // Fetch the viewer's basic information
        $basic = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        // If the call fails we check if we still have a user. The user will be
        // cleared if the error is because of an invalid accesstoken
        if (!$facebook->getUser()) {
          header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
          exit();
        }
      }
      // This fetches some things that you like . 'limit=*" only returns * values.
      // To see the format of the data you are retrieving, use the "Graph API
      // Explorer" which is at https://developers.facebook.com/tools/explorer/
      $likes = idx($facebook->api('/me/likes?limit=4'), 'data', array());
    
      // This fetches 4 of your friends.
      $friends = idx($facebook->api('/me/friends?limit=4'), 'data', array());
    
      // And this returns 16 of your photos.
      $photos = idx($facebook->api('/me/photos?limit=16'), 'data', array());
    
      // Here is an example of a FQL call that fetches all of your friends that are
      // using this app
      $app_using_friends = $facebook->api(array(
      'method' => 'fql.query',
            'query' => 'SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'
      ));
    }
    
    var_dump ($user_id);
    ?>
    

    Only need to figure out the difference.

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

Sidebar

Related Questions

Trying to create a facebook app just to learn and coming across a strange
I trying to learn web application development. I'm currently using Google App Engine to
I'm trying to learn how to get an application access token from Facebook for
i'm trying to learn how to get my own facebook & twitter wall status
Trying to learn about php's arrays today. I have a set of arrays like
I´m trying to learn C#, coming from a Python/PHP background, and I´m trying to
I am trying to write a small application to learn about developing for Facebook
Trying to learn jquery here so I took a regular javascript snippet that loops
Trying to learn some F# and I've run into a couple of hangups. Here's
Im trying to learn alot more about C code by trying to do the

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.