473,657 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to integrate my website to facebook?

semanticnotion
66 New Member
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 7173
serdar
88 New Member
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
3813
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"...
2
2243
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.
11
2433
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
7
3992
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?? Like do i need a new domain? , a server, - if so, what type ?? How do i integrate it into facebook ??? Thanks.
0
2033
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
18
11343
by: Erwin Moller | last post by:
Successful examples using PHP except Facebook?
0
1513
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...
8
9059
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?? ...
0
8302
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,...
0
8820
Oralloy
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...
0
8718
jinu1996
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...
0
5630
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();...
0
4150
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...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
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...

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.