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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:24:10+00:00 2026-06-11T08:24:10+00:00

this is my code: <html> <head> <body> <?php require_once ‘facebook-php-sdk/src/facebook.php’; $appapikey = ‘453976824647366’; $appsecret

  • 0

this is my code:

<html>
    <head>
    <body>
        <?php
        require_once 'facebook-php-sdk/src/facebook.php';

        $appapikey = '453976824647366';
        $appsecret = 'fe86f3b0b34b3ed6eb39bbce717b8062';

        $facebook = new Facebook($appapikey, $appsecret);

        $user_id = $facebook->getUser();
        echo $user_id;



        echo "<p>Hello <fb:name uid=\"$user_id\" useyou=\"false\" linked=\"false\" firstnameonly=\"true\"></fb:name>";
        ?>

    </body>

</head>
</html>

Something quite simple but i can’t manage to find why getUser is always returning 0
I would appreciate your help!

  • 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-11T08:24:12+00:00Added an answer on June 11, 2026 at 8:24 am

    The first thing to check would be

    require_once 'facebook-php-sdk/src/facebook.php';
    

    Make sure it is relative to where your php code is rather than to the server structure.

    To test this code I would probably just use the existing example provided by Facebook sdk, that way you get it working first by confidently knowing that it really works and can then tweak it as per your needed.
    Just pasting it from this link
    https://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php

    <?php
    /**
     * Copyright 2011 Facebook, Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License"); you may
     * not use this file except in compliance with the License. You may obtain
     * a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     * License for the specific language governing permissions and limitations
     * under the License.
     */
    
    require '../src/facebook.php';
    
    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
      'appId'  => '344617158898614',
      'secret' => '6dc8ac871858b34798bc2488200e503d',
    ));
    
    // Get User ID
    $user = $facebook->getUser();
    
    // We may or may not have this data based on whether the user is logged in.
    //
    // If we have a $user id here, it means we know the user is logged into
    // Facebook, but we don't know if the access token is valid. An access
    // token is invalid if the user logged out of Facebook.
    
    if ($user) {
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
    }
    
    // Login or logout url will be needed depending on current user state.
    if ($user) {
      $logoutUrl = $facebook->getLogoutUrl();
    } else {
      $loginUrl = $facebook->getLoginUrl();
    }
    
    // This call will always work since we are fetching public data.
    $naitik = $facebook->api('/naitik');
    
    ?>
    <!doctype html>
    <html xmlns:fb="http://www.facebook.com/2008/fbml">
      <head>
        <title>php-sdk</title>
        <style>
          body {
            font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
          }
          h1 a {
            text-decoration: none;
            color: #3b5998;
          }
          h1 a:hover {
            text-decoration: underline;
          }
        </style>
      </head>
      <body>
        <h1>php-sdk</h1>
    
        <?php if ($user): ?>
          <a href="<?php echo $logoutUrl; ?>">Logout</a>
        <?php else: ?>
          <div>
            Login using OAuth 2.0 handled by the PHP SDK:
            <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
          </div>
        <?php endif ?>
    
        <h3>PHP Session</h3>
        <pre><?php print_r($_SESSION); ?></pre>
    
        <?php if ($user): ?>
          <h3>You</h3>
          <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
    
          <h3>Your User Object (/me)</h3>
          <pre><?php print_r($user_profile); ?></pre>
        <?php else: ?>
          <strong><em>You are not Connected.</em></strong>
        <?php endif ?>
    
        <h3>Public profile of Naitik</h3>
        <img src="https://graph.facebook.com/naitik/picture">
        <?php echo $naitik['name']; ?>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What am I doing wrong in this HTML code: <html> <head> </head> <body> <div
OK i have this code HTML: <html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js> </script> <script type=text/javascript>
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have this code <html> <head> <script src=jquery-1.7.2.min.js type=text/javascript></script> <script src=jquery-ui-1.8.20.custom.min.js type=text/javascript></script> <script type
Ok, I have this code: <html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script> <script type=text/javascript> function get()
This is my php code: <?php require('connection.php'); $query=select title,content from blogs; echo '<html><head>'; echo
Let's have a look at this HTML code: <!DOCTYPE html> <html> <head> <title>Test</title> </head>
I'm breaking my head over this code: <html> <head> <title>Westpop</title> <link rel=stylesheet href=opmaak.css> </head>
look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
This is my code: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html> <head>

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.