I want to integrate my site to Facebook login system. I google it and at last I find this great tutorial. http://thinkdiff.net/facebook/php-sd...nect-tutorial/
But there is a problem in my authentication. Here http://www.cpantry.com/match you can find my test site. I have used php-sdk please help where I make a mistake.
here is code of my index.php - <?php
-
include_once "fbmain.php";
-
$config['baseurl'] = "http://www.cpantry.com/match/index.php";
-
-
//if user is logged in and session is valid.
-
if ($fbme){
-
//Retriving movies those are user like using graph api
-
try{
-
$movies = $facebook->api('/me/movies');
-
}
-
catch(Exception $o){
-
d($o);
-
}
-
-
//Calling users.getinfo legacy api call example
-
try{
-
$param = array(
-
'method' => 'users.getinfo',
-
'uids' => $fbme['id'],
-
'fields' => 'name,current_location,profile_url',
-
'callback'=> ''
-
);
-
$userInfo = $facebook->api($param);
-
}
-
catch(Exception $o){
-
d($o);
-
}
-
-
//update user's status using graph api
-
if (isset($_POST['tt'])){
-
try {
-
$statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> $_POST['tt'], 'cb' => ''));
-
} catch (FacebookApiException $e) {
-
d($e);
-
}
-
}
-
-
//fql query example using legacy method call and passing parameter
-
try{
-
//get user id
-
$uid = $facebook->getUser();
-
//or you can use $uid = $fbme['id'];
-
-
$fql = "select name, hometown_location, sex, pic_square from user where uid=" . $uid;
-
$param = array(
-
'method' => 'fql.query',
-
'query' => $fql,
-
'callback' => ''
-
);
-
$fqlResult = $facebook->api($param);
-
}
-
catch(Exception $o){
-
d($o);
-
}
-
}
-
?>
-
<!DOCTYPE html>
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-
<title>PHP SDK & Graph API base FBConnect Tutorial | Thinkdiff.net</title>
-
</head>
-
<body>
-
<div id="fb-root"></div>
-
<script type="text/javascript">
-
window.fbAsyncInit = function() {
-
FB.init({appId: '<?=$fbconfig['appid' ]?>', status: true, cookie: true, xfbml: true});
-
-
/* All the events registered */
-
FB.Event.subscribe('auth.login', function(response) {
-
// do something with response
-
login();
-
});
-
FB.Event.subscribe('auth.logout', function(response) {
-
// do something with response
-
logout();
-
});
-
};
-
(function() {
-
var e = document.createElement('script');
-
e.type = 'text/javascript';
-
e.src = document.location.protocol +
-
'//connect.facebook.net/en_US/all.js';
-
e.async = true;
-
document.getElementById('fb-root').appendChild(e);
-
}());
-
-
function login(){
-
document.location.href = "<?=$config['baseurl']?>";
-
}
-
function logout(){
-
document.location.href = "<?=$config['baseurl']?>";
-
}
-
</script>
-
<style type="text/css">
-
.box{
-
margin: 5px;
-
border: 1px solid #60729b;
-
padding: 5px;
-
width: 500px;
-
height: 200px;
-
overflow:auto;
-
background-color: #e6ebf8;
-
}
-
</style>
-
-
<h3>PHP SDK & Graph API base FBConnect Tutorial | Thinkdiff.net</h3>
-
<?php if (!$fbme) { ?>
-
You've to login using FB Login Button to see api calling result.
-
<?php } ?>
-
<p>
-
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
-
</p>
-
-
<!-- all time check if user session is valid or not -->
-
<?php if ($fbme){ ?>
-
<table border="0" cellspacing="3" cellpadding="3">
-
<tr>
-
<td>
-
<!-- Data retrived from user profile are shown here -->
-
<div class="box">
-
<b>User Information using Graph API</b>
-
<?php d($fbme); ?>
-
</div>
-
</td>
-
<td>
-
<div class="box">
-
<b>User likes these movies | using graph api</b>
-
<?php d($movies); ?>
-
</div>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<div class="box">
-
<b>User Information by Calling Legacy API method "users.getinfo"</b>
-
<?php d($userInfo); ?>
-
</div>
-
</td>
-
<td>
-
<div class="box">
-
<b>FQL Query Example by calling Legacy API method "fql.query"</b>
-
<?php d($fqlResult); ?>
-
</div>
-
</td>
-
</tr>
-
</table>
-
<div class="box">
-
<form name="" action="<?=$config['baseurl']?>" method="post">
-
<label for="tt">Status update using Graph API</label>
-
<br />
-
<textarea id="tt" name="tt" cols="50" rows="5">Write your status here and click 'submit'</textarea>
-
<br />
-
<input type="submit" value="Update My Status" />
-
</form>
-
<?php if (isset($statusUpdate)) { ?>
-
<br />
-
<b style="color: red">Status Updated Successfully! Status id is <?=$statusUpdate['id']?></b>
-
<?php } ?>
-
</div>
-
<?php } ?>
-
-
</body>
-
</html>
1 7173
What error do you get when trying to login?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: mfasoccer |
last post by:
Hey guys I'm writing a facebook bot program. Currently I am stuck at
the login screen. My approach was to take a password and convert it to
md5 along with the challenge parameter that you will notice if you go
to facebook's website. To give a better idea of this I'll show you
their login form:
<form method="post" name="loginform" action="https://
login.facebook.com/login.php" onsubmit="quicklogin();"><input
type="hidden"...
|
by: hmchkus |
last post by:
Hi,
How can I integrate part of information from another website on my
page?
For example, a table of schedule, weather, stock info...
I would like to know both way:
1. redirect the client browser to another site
2. serve content through my website.
|
by: Dual_b00t |
last post by:
Hi I am a beginner PHP programmer so I decided i would create a
facebook group for us newbs to share and help each other out..
http://www.facebook.com/group.php?gid=20845788472
its brand new but will be adding links to tutorials and videos also it
has a forum to chat etc etc
see you guys there sometime
|
by: George Lft |
last post by:
been trying to build an application in facebook, but couldn't understand anything about it. Went through their tutorial like 10 times, but can't understand.
Where should i start to build it?? Like do i need a new domain? , a server, - if so, what type ?? How do i integrate it into facebook ???
Thanks.
|
by: Dutt |
last post by:
You know how Facebook is getting popularity nowadays. If you are
really interested about facebook and you are .NET professional, I know
the options provided by facebook web application are not enough to
you. So this article provides how can you extend your facebook
features with .NET Framework using Facebook.NET SDK.
http://msdotnetsupport.blogspot.com/2007/11/writing-facebook-applications-in-net.html
| |
by: Erwin Moller |
last post by:
Successful examples using PHP except Facebook?
|
by: waqasahmed996 |
last post by:
Hi
i am not sure whether am i posting this message on right section.
i have a website to share quotes on Facebook. (http://www.screamd.com/)
Actually i am using Link Button on my site. Two weeks before when anybody click on Like button then this 'quote' appears on his/her friends home page/news feed. And link refer to my own site.
But now this appear only a text not a link. Even quotes which were links two weeks ago now a simple...
|
by: gamazone |
last post by:
hi to all
is it possible to auto fill and auto login the facebook login form?
i am developing a web application in which , user will in put his,say for facebook, login information in his home page and upon
clicking a button , facebook will open and entered information will get auto filled in the login form and form will be auto submitted
i tried javascript but, i have doubt , can the document object refer to the facebookpage?? ...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |