Social Network Integration


Published on

This presentation discusses the importance of social networking services' integration to websites and sample coding using twitter widget and facebook sdk.

Published in: Technology

Social Network Integration

  1. 1. Social Network Integration<br />By John Michael Vincent D. Dalisay<br />Jr. Software Developer<br />
  2. 2. Contents<br />Social Networking Service<br />How important is SNS<br />Video<br />Sample Applications<br />Descriptions and Screenshots<br />Coding<br />JavaScript with FB.ui and Twitter Widget<br />Using Facebook PHP SDK<br />
  3. 3. social networking service<br />A social networking service is an online service, platform, or site that focuses on building and reflecting of social networks or social relations among people, e.g., who share interests and/or activities. <br />Most of them are web based. E.g. (facebook, twitter)<br />
  4. 4. How important/useful is this?<br />See video: Facebook and Websites.mp4<br />(Video from SmartBCN)<br />
  5. 5. Sample Applications<br /> - Online ePUB e-Book Storage. Store, Download, Read and Share your E-Books.<br />DO-CMS websites:<br /><br />
  6. 6.<br />The user can share an ebook to facebook or twitter with his review and rating. The site will be known to his facebook friends or twitter followers.<br />
  7. 7.<br />
  8. 8.<br />The user can share list of links of ebooks to facebook. So it is possible for his facebook friends to view lots of ebook profile at His friends could also be encouraged to sign up for an eforuli account.<br />
  9. 9.<br />
  10. 10.<br />Special shows/events shown on their home page can be shared to facebook or twitter<br />
  11. 11.<br />
  12. 12.<br /> facebook page photos are synced to their website photos. We save server disk space since the photos are stored in facebook and not in our server.<br />
  13. 13. (site album)<br />
  14. 14. (FB album)<br />
  15. 15.<br />We can also get the events created from their facebook page and post it on their website.<br />
  16. 16. Coding<br />Sharing via FB.ui and Twitter Widget<br />Using Facebook PHP SDK<br />
  17. 17. Sharing via FB.ui and Twitter Widget<br />We will code about how to share site contents to user’s facebook wall and twitter account.<br />
  18. 18. JavaScript with FB.ui<br />Create an app for your site:<br />Your App ID and App Secret ID will be generated.<br />
  19. 19. JavaScript with FB.ui<br />Include the following in your php document<br /><div id="fb-root"></div><br /><script src=""></script><br />
  20. 20. JavaScript with FB.ui<br />Create your function. Include variables for data to be displayed.<br /><script type='text/javascript'><br /> function post_to_wall( event_id, event_title, event_date){<br /> }<br /></script><br />
  21. 21. JavaScript with FB.ui<br />Place the following inside your function.<br />FB.init({ <br /> appId:'178864032154187', <br />cookie:true, <br />status:true, <br />xfbml:true<br /> });<br />appId– is the App ID generated on App Creation earlier.<br />
  22. 22. JavaScript with FB.ui<br />Place the following underFB.init code. This is where we specify the default contents of the post<br />FB.ui(<br /> {<br /> method: 'feed',<br /> name: event_title + ' on ' + event_date,<br /> link: '',<br /> picture: '' + event_id,<br /> caption: 'Events @ Calleza Grill',<br /> description: 'Calleza Grill is Antipolo’s premiere live music venue. This bar and restaurant has evolved into one of the best live music venues in the area. Calleza is the ideal venue for your night out.',<br /> message: 'Hi friends! Calleza Grill will be having a great show on ' + event_date + '!'<br /> },<br />);<br />
  23. 23. JavaScript with FB.ui<br />Place the following insideFB.ui function if you want the user prompted with a publishing confirmation.<br /> function(response) {<br /> if (response && response.post_id) {<br /> alert('Post was published.');<br /> }else{<br /> //alert('Post was not published.');<br /> }<br /> }<br />
  24. 24. JavaScript with FB.ui<br />Given the values to be processed, the button code would be something like this:<br /><input type='button' <br /> value='Share on Facebook‘<br /> class='share-buttons' <br />onClick='post_to_wall( <?php echo $event_id; ?>, "<?php echo $event_title; ?>", "<?php echo $start_date; ?>" )' <br />id='fbbtn' /><br />
  25. 25. That was the code used here…<br />
  26. 26. JavaScript with Twitter Widget<br />We’ll proceed with the codes on sharing via twitter.<br />Unlike facebook, you don’t have to create an app in twitter, just include the widget:<br /><script src="" type="text/javascript"><br /></script><br />
  27. 27. JavaScript with Twitter Widget<br />Create your function<br /><script type='text/javascript'><br /> function share_on_twitter( event_title, event_date ){<br /> }<br /></script> <br />
  28. 28. JavaScript with Twitter Widget<br />Inside your function, you should have code something like this:<br />varurl = "";<br />vartext = "In Calleza Grill: " + event_title + " on " + event_date + "!";<br />"" + text + "&url=" + url,'name','height=300,width=500,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=20,left=20');<br />
  29. 29. JavaScript with Twitter Widget<br />Given the values to be processed, the button code would be something like this:<br /><input type='button' value='Share on Twitter' class='share-buttons' onClick='share_on_twitter( "<?php echo $event_title; ?>", "<?php echo $start_date; ?>" )' id='twitterbtn' /><br />
  30. 30. And that was the code used here…<br />
  31. 31. Using Facebook PHP SDK<br />We will retrieve photo albums from a facebook page and display it on a website.<br />
  32. 32. Using Facebook PHP SDK<br />Download PHP SDK here:<br />Store the SDK in your web directory<br />
  33. 33. Using Facebook PHP SDK<br />Include the following code in your php document:<br />include 'calleza/FQL/fb-sdk/src/facebook.php';<br /> $facebook = new Facebook(array(<br /> 'appId' => '178864032154187',<br /> 'secret' => '910dfaf91735b2c3422e0b0756a32902',<br /> 'cookie' => true, // enable optional cookie support<br /> ));<br />facebook.php – included in the SDK<br />appId and secret – generated when we created an app earlier<br />
  34. 34. Using Facebook PHP SDK<br />Next is the following code. Facebook query language (FQL) is just like SQL. The following queries the albums of the facebook page.<br /> echo "<p style='font-weight: bold;'>Calleza Grill Photo Albums</p>";<br /> $fql = "SELECT aid, cover_pid, name FROM album WHERE owner=217052582900 and aid != '217052582900_225185' and aid != '217052582900_131309'";<br /> $param = array(<br /> 'method' => 'fql.query',<br /> 'query' => $fql,<br /> 'callback' => ''<br /> );<br /> $fqlResult = $facebook->api($param);<br />
  35. 35. Using Facebook PHP SDK<br />Next, we’re gonna loop throught the albums and create another query to get the album cover image.<br />foreach( $fqlResult as $keys => $values ){<br /> //to get album cover<br /> $fql2 = "select src from photo where pid = '" . $values['cover_pid'] . "'";<br /> $param2 = array(<br /> 'method' => 'fql.query',<br /> 'query' => $fql2,<br /> 'callback' => ''<br /> );<br /> $fqlResult2 = $facebook->api($param2);<br />foreach( $fqlResult2 as $keys2 => $values2){<br /> $album_cover = $values2['src'];<br /> }<br /> echo "<div style='padding: 10px; width: 150px; height: 170px; float: left;'>";<br /> echo "<a href='" . $values['aid'] . "&name=" . $values['name'] . "'>";<br /> echo "<imgsrc='$album_cover' border='1'>";<br /> echo "</a><br />";<br /> echo $values['name'];<br /> echo "</div>";<br /> }<br />
  36. 36. And that was the code used in here…<br />
  37. 37. Using Facebook PHP SDK<br />There are so many other data that we can query from facebook.<br />For more info, visit<br />
  38. 38. References<br />Wikipedia<br /><br /><br />
  39. 39. The End<br />