10 Replies - 25942 Views - Last Post: 22 June 2010 - 12:16 AM

#1 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2246
  • View blog
  • Posts: 9,236
  • Joined: 18-February 07

Week #21 Facebook Platform API

Post icon  Posted 24 May 2010 - 11:02 AM

Week #21: Facebook API
Posted Image

Introduction
Over the last few years Facebook as become a important part of many peoples lives and has made stunning profits as a result. Being able to integrate with facebook is becoming an important part of the expected suite of features your users may be looking for. This weeks challenge is to try your hand at the Facebook API.

Getting Started
Facebook offers developers a host of options when it comes to integration.
Facebook Developer's Website is the best place to start.
  • Graph API -- The Graph API is the core to integrating with the facebook platform -- this allows you to exchange data with Facebook. Regardless of which SDK you choose, you will need to familiarize yourself with the Graph API.
  • Authentication -- Facebook's Authentication is quickly becoming a common integration allowing users to authenticate via facebook.
  • Social plugins -- Allow users to like, or comment on items on your website, share content to/from other sites. These plugins are fairly simple to integrate into your website allowing you to bring facebook into your users experience.
  • Open Graph Protocol -- Integrate your pages into the social graph for a tighter integration with the Facebook experience.


Facebook SDK's -- Facebook offers a number of SDK options for developers


Facebook Documentation Wiki -- This page has some basic guides on how to get started and some interesting articles on various aspects of the platform.

And For the really advanced integrations there are:


Tutorials/Blogs
PHP


Ideas
    Basic
  • Add a Social Plugin to your web page
  • Authenticate a user though facebook
  • Create a log of your [friends] status updates
  • An application that update your wall the weather in your city
    Intermediate
  • Create a facebook status randomizer/shuffle
  • Create a photo-album sync. app to sync photos with a directory and facebook.
    Advanced
  • Create a graph of your social network


Other info
The above listed API/SDK's are the "official" SDKs but there is ofcourse work in any number of other platforms.


Is This A Good Question/Topic? 3
  • +

Replies To: Week #21 Facebook Platform API

#2 Jono20201  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: Week #21 Facebook Platform API

Posted 24 May 2010 - 01:05 PM

Very funny timing. I was just starting to do this anyways. I'm trying to make a site with facebook and twitter intergration. Can we do twitter next please?
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Week #21 Facebook Platform API

Posted 24 May 2010 - 01:07 PM

Jono, we did Twitter on Week #3 ( http://www.dreaminco...ge-twitter-api/ ) but you're welcome to submit what you do in the challenge. These challenges are always open.
Was This Post Helpful? 0
  • +
  • -

#4 Jono20201  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: Week #21 Facebook Platform API

Posted 24 May 2010 - 02:00 PM

View Postskyhawk133, on 24 May 2010 - 12:07 PM, said:

Jono, we did Twitter on Week #3 ( http://www.dreaminco...ge-twitter-api/ ) but you're welcome to submit what you do in the challenge. These challenges are always open.



Tell you how much I pay attention. Watch out facebook and Twitter. I'm coming :P

Also, for anyone using facebooks javascript API I just made/copy'd this from the net..

<?

require 'facebook.php';

// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => 'xxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'cookie' => true,
));

// We may or may not have this data based on a $_GET or $_COOKIE based session.
//
// If we get a session here, it means we found a correctly signed session using
// the Application Secret only Facebook and the Application know. We dont know
// if it is still valid until we make an API call using the session. A session
// can become invalid if it has already expired (should not be getting the
// session back in this case) or if the user logged out of Facebook.
$session = $facebook->getSession();

$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}

// login or logout url will be needed depending on current user state.
if ($me) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>php-sdk</title>
    <style>
      body {
        font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
        text-decoration: none;
        color: #3b5998;
      }
      h1 a:hover {
        text-decoration: underline;
      }
    </style>
  </head>
  <body>
    <!--
      We use the JS SDK to provide a richer user experience. For more info,
      look here: http://github.com/facebook/connect-js
      
      FACEBOOK Javascript INIT CODE. DO NOT EDIT.
    -->
    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId   : '<?php echo $facebook->getAppId(); ?>',
          session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
          status  : true, // check login status
          cookie  : true, // enable cookies to allow the server to access the session
          xfbml   : true // parse XFBML
        });

        // whenever the user logs in, we refresh the page
        FB.Event.subscribe('auth.login', function() {
          window.location.reload();
        });
      };

      (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
	  
	  function postToWall(){
		FB.ui(
		  {
			method: 'stream.publish',
			message: 'Trying out my sites facebook connect.... BTW, my next project is to do with facebook. Hold on tight...'
		  },
		  function(response) {
			if (response && response.post_id) {
			  alert('Post was published.');
			} else {
			  alert('Post was not published.');
			}
		  }
		);
	}

    </script>
    <?php 
		if($me){
			?>
    	<a href="javascript:postToWall();">Post</a>
        	<?
		} else {
			
			echo "<fb:login-button></fb:login-button>";
			
		}
	?>
  </body>
</html>




Not that it is any use to anyone...

This post has been edited by Jono20201: 24 May 2010 - 02:02 PM

Was This Post Helpful? 2
  • +
  • -

#5 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2246
  • View blog
  • Posts: 9,236
  • Joined: 18-February 07

Re: Week #21 Facebook Platform API

Posted 24 May 2010 - 09:25 PM

Well at work we integrated a couple of social plugins which was dead easy. but I am not finding the api's very easy at all!!! My attempt to make a stand alone Python app failed miserably and my attempt to use the Python version of the Google App Engine is not quite going as well as I would have hoped... I think tomorrow I might change over to java and see if I can't get something working though JSP. Python has never let me down before... but this time... I dunno, I am really frustrated.
Was This Post Helpful? 1
  • +
  • -

#6 Jono20201  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: Week #21 Facebook Platform API

Posted 25 May 2010 - 01:21 AM

I managed to use the Javascript API alot yesterday. Tonight I am going to use the FB.ui as a test. I also want to intergrate the api into my site. This could be fun....
Was This Post Helpful? 0
  • +
  • -

#7 moro5000  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 12-December 09

Re: Week #21 Facebook Platform API

Posted 25 May 2010 - 06:34 AM

thanxxxxxxxx
Was This Post Helpful? 0
  • +
  • -

#8 amitchhajer  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 78
  • Joined: 30-January 10

Re: Week #21 Facebook Platform API

Posted 25 May 2010 - 08:20 AM

i am missing many of the challenges because of the university exams...will be all of them later. For me each challenge will be half a week, so that i can cop-up. :)
Was This Post Helpful? 0
  • +
  • -

#9 fsloke  Icon User is offline

  • D.I.C Regular

Reputation: 25
  • View blog
  • Posts: 412
  • Joined: 19-December 07

Re: Week #21 Facebook Platform API

Posted 25 May 2010 - 09:06 AM

It open my eyes.... Thanks DIC!!!
Was This Post Helpful? 0
  • +
  • -

#10 TheOrderInChaos  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 25-March 10

Re: Week #21 Facebook Platform API

Posted 25 May 2010 - 10:29 AM

Looking forward to trying my hand at this. Enjoying your weeks of code.
Was This Post Helpful? 0
  • +
  • -

#11 aniri  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 54
  • View blog
  • Posts: 657
  • Joined: 24-November 09

Re: Week #21 Facebook Platform API

Posted 22 June 2010 - 12:16 AM

I've tested most of their social plugins on my site.

Here's the result :)

This post has been edited by aniri: 22 June 2010 - 12:24 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1