Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2012, 08:54 AM   PM User | #1
karubum
New to the CF scene

 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
karubum is an unknown quantity at this point
Facebook Connect -> Call back (close po-up) -> FB user info check -> setter query

I am trying to write a program:

1) There is a Facebook Login button in index.php
When you click on it, the facebook connect will be appear with popup window
2) When you back callback url the pop-up window will be closed.
3) Graph API will retrieve user info ( (email,user name, profile picture url,gender ), When these data come with jquery, all info will be send to server. Then we retrieve all these data to index2.php page. ( We will do these by JSON )

Shortly: Facebook Connect -> Call back (close po-up) -> FB user info check -> setter query -> getter query -> display data

I have index.php and able to get fb connect and get user data by Graph API. But I do not know how to pass data to server and retrive them to index2.php

Here is my index.php:

<?php

//uses the PHP SDK. Download from https://github.com/facebook/php-sdk
//require 'facebook-platform/php/facebook.php';
require 'facebook-php-sdk/src/facebook.php';

$facebook = new Facebook(array(
'appId' => '289329761120769',
'secret' => '9cad1979d8379605dc04e3c48bf7c18c'
));

$userId = $facebook->getUser();

?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<?php if ($userId) {
$userInfo = $facebook->api('/' + $userId); ?>
Welcome <?= $userInfo['name'] ?> </br>

gender <?= $userInfo['gender'] ?> </br>

username <?= $userInfo['username'] ?> </br>

email <?= $userInfo['email'] ?> </br>

website <?= $userInfo['website'] ?> </br>

<img src="https://graph.facebook.com/<?= $userInfo['id'] ?>/picture"/> </br>

<?php } else { ?>
<div id="fb-root"></div>

<div class="fb-login-button" scope="email,user_website">
Login with Facebook
</div>
<!--fb:login-button" data-scope="email,user_website"></fb:login-button-->

<?php } ?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '289329761120769',
status : true,
cookie : true,
xfbml : true,
oauth : true
});

FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
};

(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</body>
</html>
karubum is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:50 PM.


Advertisement
Log in to turn off these ads.