-2
Ajax Facebook Connect with jQuery & PHP
I can’t run Facebook on the local machine. I want to implement Login with Facebook on my site more I would like to test locally above this login I am trying to implement!
-2
Ajax Facebook Connect with jQuery & PHP
I can’t run Facebook on the local machine. I want to implement Login with Facebook on my site more I would like to test locally above this login I am trying to implement!
1
Here is a very simplified example of how to use the facebook API for PHP, which is here:
<?php
require '../src/facebook.php';
$facebook = new Facebook( array(
'appId' => 'PONHA SEU APPID AQUI',
'secret' => 'PONHA SEU TOKEN AQUI',
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $fberror) {
error_log($fberror);
$user = null;
}
$link = $facebook->getLogoutUrl();
} else {
$link = $facebook->getLoginUrl();
}
?>
<!doctype html>
<html>
<body>
<?php if ($user) { ?>
<a href="<?php echo $link; ?>">Logout</a>
<?php } else { ?>
<a href="<?php echo $link; ?>">Login com Facebook</a>
<?php } ?>
<?php if ($user) { ?>
<h3>Voce:</h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
<h3>Perfil:</h3>
<pre><?php print_r($user_profile); ?></pre>
<?php } else {?>
<h3>Erro:</h3>
<?php echo $fberror; ?>
<?php } ?>
</body>
</html>
Test on your machine with your ID and TOKEN, and let us know if you are experiencing any errors.
0
Friend, you will need to create an alias for your project. Today you are accessing localhost/your project. This way Facebook can not understand, you will need to create an alias for your project, leaving the access to it so local.youproject.com.br. To do this, take a look at this post: http://www.raphaelfiga.com/desenvolvimento/instalando-configurando-virtualhost-apache-windows/
I hope I’ve helped.
Browser other questions tagged php facebook authentication oauth virtualhost
You are not signed in. Login or sign up in order to post.
Yes, you need a powerful machine to run facebook on the local machine... Joking aside, what is the problem you are having?
– Bacco
The problem is that I want to test "Login with Facebook" on the local machine (Localhost) and then implement on my site that is not yet hosted
– Kayata14
The problem is you want to test? :)
– Bacco
No, more like entering my site than it is on the local server
– Kayata14
Your local server runs PHP?
– Bacco
Yes, it works very well!
– Kayata14
Test the code below on it then, which should work normally. If there is an error, then you warn.
– Bacco