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!
The first thing to check would be
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