472,956 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,956 software developers and data experts.

How to integrate my website to facebook?

semanticnotion
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.Herehttp://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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     include_once "fbmain.php";
  3.     $config['baseurl']  =   "http://www.cpantry.com/match/index.php";
  4.  
  5.     //if user is logged in and session is valid.
  6.     if ($fbme){
  7.         //Retriving movies those are user like using graph api
  8.         try{
  9.             $movies = $facebook->api('/me/movies');
  10.         }
  11.         catch(Exception $o){
  12.             d($o);
  13.         }
  14.  
  15.         //Calling users.getinfo legacy api call example
  16.         try{
  17.             $param  =   array(
  18.                 'method'  => 'users.getinfo',
  19.                 'uids'    => $fbme['id'],
  20.                 'fields'  => 'name,current_location,profile_url',
  21.                 'callback'=> ''
  22.             );
  23.             $userInfo   =   $facebook->api($param);
  24.         }
  25.         catch(Exception $o){
  26.             d($o);
  27.         }
  28.  
  29.         //update user's status using graph api
  30.         if (isset($_POST['tt'])){
  31.             try {
  32.                 $statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> $_POST['tt'], 'cb' => ''));
  33.             } catch (FacebookApiException $e) {
  34.                 d($e);
  35.             }
  36.         }
  37.  
  38.         //fql query example using legacy method call and passing parameter
  39.         try{
  40.             //get user id
  41.             $uid    = $facebook->getUser();
  42.             //or you can use $uid = $fbme['id'];
  43.  
  44.             $fql    =   "select name, hometown_location, sex, pic_square from user where uid=" . $uid;
  45.             $param  =   array(
  46.                 'method'    => 'fql.query',
  47.                 'query'     => $fql,
  48.                 'callback'  => ''
  49.             );
  50.             $fqlResult   =   $facebook->api($param);
  51.         }
  52.         catch(Exception $o){
  53.             d($o);
  54.         }
  55.     }
  56. ?>
  57. <!DOCTYPE html>
  58. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
  59.     <head>
  60.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  61.         <title>PHP SDK & Graph API base FBConnect Tutorial | Thinkdiff.net</title>
  62.     </head>
  63. <body>
  64.     <div id="fb-root"></div>
  65.         <script type="text/javascript">
  66.             window.fbAsyncInit = function() {
  67.                 FB.init({appId: '<?=$fbconfig['appid' ]?>', status: true, cookie: true, xfbml: true});
  68.  
  69.                 /* All the events registered */
  70.                 FB.Event.subscribe('auth.login', function(response) {
  71.                     // do something with response
  72.                     login();
  73.                 });
  74.                 FB.Event.subscribe('auth.logout', function(response) {
  75.                     // do something with response
  76.                     logout();
  77.                 });
  78.             };
  79.             (function() {
  80.                 var e = document.createElement('script');
  81.                 e.type = 'text/javascript';
  82.                 e.src = document.location.protocol +
  83.                     '//connect.facebook.net/en_US/all.js';
  84.                 e.async = true;
  85.                 document.getElementById('fb-root').appendChild(e);
  86.             }());
  87.  
  88.             function login(){
  89.                 document.location.href = "<?=$config['baseurl']?>";
  90.             }
  91.             function logout(){
  92.                 document.location.href = "<?=$config['baseurl']?>";
  93.             }
  94. </script>
  95. <style type="text/css">
  96.     .box{
  97.         margin: 5px;
  98.         border: 1px solid #60729b;
  99.         padding: 5px;
  100.         width: 500px;
  101.         height: 200px;
  102.         overflow:auto;
  103.         background-color: #e6ebf8;
  104.     }
  105. </style>
  106.  
  107.     <h3>PHP SDK & Graph API base FBConnect Tutorial | Thinkdiff.net</h3>
  108.     <?php if (!$fbme) { ?>
  109.         You've to login using FB Login Button to see api calling result.
  110.     <?php } ?>
  111.     <p>
  112.         <fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
  113.     </p>
  114.  
  115.     <!-- all time check if user session is valid or not -->
  116.     <?php if ($fbme){ ?>
  117.     <table border="0" cellspacing="3" cellpadding="3">
  118.         <tr>
  119.             <td>
  120.                 <!-- Data retrived from user profile are shown here -->
  121.                 <div class="box">
  122.                     <b>User Information using Graph API</b>
  123.                     <?php d($fbme); ?>
  124.                 </div>
  125.             </td>
  126.             <td>
  127.                 <div class="box">
  128.                     <b>User likes these movies | using graph api</b>
  129.                      <?php d($movies); ?>
  130.                 </div>
  131.             </td>
  132.         </tr>
  133.         <tr>
  134.             <td>
  135.                 <div class="box">
  136.                     <b>User Information by Calling Legacy API method "users.getinfo"</b>
  137.                     <?php d($userInfo); ?>
  138.                 </div>
  139.             </td>
  140.             <td>
  141.                 <div class="box">
  142.                     <b>FQL Query Example by calling Legacy API method "fql.query"</b>
  143.                     <?php d($fqlResult); ?>
  144.                 </div>
  145.             </td>
  146.         </tr>
  147.     </table>
  148.     <div class="box">
  149.         <form name="" action="<?=$config['baseurl']?>" method="post">
  150.             <label for="tt">Status update using Graph API</label>
  151.             <br />
  152.             <textarea id="tt" name="tt" cols="50" rows="5">Write your status here and click 'submit'</textarea>
  153.             <br />
  154.             <input type="submit" value="Update My Status" />
  155.         </form>
  156.         <?php if (isset($statusUpdate)) { ?>
  157.             <br />
  158.             <b style="color: red">Status Updated Successfully! Status id is <?=$statusUpdate['id']?></b>
  159.          <?php } ?>
  160.     </div>
  161.     <?php } ?>
  162.  
  163.     </body>
  164. </html>
Mar 11 '11 #1
1 7032
serdar
88
What error do you get when trying to login?
Mar 13 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
2
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...
11
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...
7
George Lft
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??...
0
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...
18
by: Erwin Moller | last post by:
Successful examples using PHP except Facebook?
0
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...
8
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.