Facebook Application Development PHP SDK 3.1.1


Hits: 3541  

Facebook is going to upgrade Developer API by 1st October 2011. All sites and apps on Facebook will migrate to OAuth 2.0 through this update. This will ensure that users browsing Facebook over HTTPS will have a great experience over a secure connection. We can imagine that these changes will make facebook better and more secure while browsing apps.

Reminder- Upgrade Your App to OAuth 2.0 and HTTPS by October 1st

Today I get this notification from facebook 🙁
We can upgrade existing FB Apps created using old version of SDK see here

Code sample for FB Login Button / Link
Upgrade Your App to OAuth 2.0 and HTTPS

Code sample for FB publish & get user information
Upgrade Your App to OAuth 2.0 and HTTPS

Review Demo App using PHP SDK 3.1.1
Upgrade Your App to OAuth 2.0 and HTTPS

Login to App
Upgrade Your App to OAuth 2.0 and HTTPS

Advanced permission for App with PHP SDK 3.1.1

Upgrade Your App to OAuth 2.0 and HTTPS

Updates posted on wall using PHP SDK 3.1.1

Upgrade Your App to OAuth 2.0 and HTTPS

Get more help here: FBTerminal or discuss here skype: svnlabs 🙂

Exceptions with Facebook Apps


Hits: 4304  

OAuthException: Error validating access token: Session has expired at unix time 1311357600. The current unix time is 1311357734

Request FB Access Token each & every time…

Rotate Apps…


OAuthException: (#1) An unknown error occurred

Sometime facebook block App’s domain and text, images, links etc. used on apps, You can use URL Linter to cross check

https://developers.facebook.com/tools/lint?url=svnlabs.com

http://forum.developers.facebook.net/viewtopic.php?id=78958 🙁

Provide UTF8 Content…


OAuthException: (#210) User not visible

The actual error is “Your friend do not allow posts on his wall”


OAuthException [message] => (#341) Feed action request limit reached


OAuthException: (#100) The post’s links must directly to the application’s connect or canvas URL

This can be solved by going into application settings -> advanced -> and setting the Stream post URL security to disabled.


Use JavaScript API to get user’s real country / location…


Add valid conditions before publishing…


I learned from Facebook…

1. Build stuff that will get used. Fast.
2. Engineering Innovation
3. Small Team, Big Impact
4. Connecting the World
5. Prime Time Hack


RoadMap
*******
Keep yourself updated with all latest changes on FB API 😉

http://developers.facebook.com/roadmap/

iWishYou – My Best Wishes with MP3 on Facebook


Hits: 3039  

My Best Wishes with MP3 on Facebook

iWishYou is a facebook application where you can share Wishes / Greeting as songs for friend’s birthday, events, daily wishes.

A wish is a hope or desire for something, iWishYou attract users with nice share on FB Walls. It is the better way to express your emotions to your friends & circle.

My Best Wishes with MP3 on Facebook

Get PID from FBID


Hits: 6714  
<?php

include("lib/facebook.php");

$APPLICATION_ID = "xxxxxxxxxxxxxxx";
$APPLICATION_SECRET = "yyyyyyyyyyyyyyyyyyyyyyyyyyyy";

$facebook = new Facebook(array(
'appId'  => $APPLICATION_ID,
'secret' => $APPLICATION_SECRET,
'cookie' => true
));

$fbid="xxxxxxxxxx";

$fql = "SELECT pid FROM photo WHERE object_id=".$fbid;

$param  =   array(
 'method'    => 'fql.query',
 'query'     => $fql,
 'callback'  => ''
);

$fqlResult   =   $facebook->api($param);

$fql = "SELECT src_small, src_big  FROM photo WHERE pid = '".$fqlResult[0]['pid']."' ";

$param  =   array(
 'method'    => 'fql.query',
 'query'     => $fql,
 'callback'  => ''
);

$fqlResult   =   $facebook->api($param);

echo $fqlResult[0]['src_big'];
print_r(getimagesize($fqlResult[0]['src_big']));

echo "http://www.facebook.com/photo.php?fbid='".$fbid."' ";

?>

Life is the art of drawing without an eraser.So be careful while taking any small decisions about the valuable pages of life.

Save Facebook Profile Photo


Hits: 2996  
<?php

$facebook_uid = '100000296428149';
$sourcecode = save_facebook_profile_photo($facebook_uid);

print_r($sourcecode);

file_put_contents("images/".$facebook_uid.".jpg", file_get_contents($sourcecode['url'])); //this is name of new file that i save

function save_facebook_profile_photo( $id )
{
    $options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_USERAGENT      => "spider", // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
        CURLOPT_TIMEOUT        => 120,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    );
    
    $url = "http://graph.facebook.com/".$id."/picture";

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    //$header['errno']   = $err;
    //$header['errmsg']  = $errmsg;
    //$header['content'] = $content;
    print($header[0]);
    return $header;
}  

?>

Amazon S3 & Facebook Fanpage app


Hits: 10624  

I want to link Amazon S3 https object like “https://s3.amazonaws.com/bucket/index.html” to facebook iframed fan page…
But it returned error….

405 Method Not Allowed
Code: MethodNotAllowed
Message: The specified method is not allowed against this resource.
ResourceType: OBJECT
Method: POST
RequestId: XXXXXXXXXXXXX
HostId: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

OR

PreconditionFailedAt least one of the pre-conditions you specified did not holdBucket POST must be of the enclosure-type multipart/form-data….. 🙁

OR

<Error>
<Code>PreconditionFailed</Code>
<Message>At least one of the pre-conditions you specified did not hold</Message>
<Condition>Bucket POST must be of the enclosure-type multipart/form-data</Condition>
<RequestId>F681CE6EB61CFAA3</RequestId>
<HostId>hMQd22w34G0TpwISr1gQDB/TdUniRjhJ355Scc9RxOWreDDb5XWYwEFzutkhjX72</HostId>
</Error>

After few searches I got link…. but not helpful 🙁
http://www.hyperarts.com/blog/facebook-secure-browsing-https-iframe-tabs-mixed-content-warnings/

Finally, I got good article on AWS Forum..
https://forums.aws.amazon.com/thread.jspa?messageID=228930

I came to know that facebook loads the requested HTTPS S3 URL “https://s3.amazonaws.com/bucket/index.html” by sending a form POST and injected some content into the iframe, but S3 have POST for file uploading only… so it returned “MethodNotAllowed”

Bucket Policies won’t work in this condition… 🙁

Now, I have few options to use S3 HTTPS Object “https://s3.amazonaws.com/bucket/index.html” in facebook iframed fan page…

1. Run a HTTPS Apache server that can load S3 HTTPS Object with POST method and supply to fan page 🙂
2. Load S3 HTTPS Object using another iframe on any server… see code below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Fan Page - Amazon S3</title>
</head>

<body>
<iframe frameborder="0" style="width: 520px; height: 800px;" src="https://s3.amazonaws.com/svwpmu/index.html" scrolling="no"></iframe>
</body>
</html>

You can check videos released on blog 9th May 2011 for more detailed installation…

I have partnered with Shelle Kind of facebook social marketing and we have released the Amazon S3 / EC2 Solution for Facebook fanpage apps.

Partner: Shelle-K | Custom graphic and web developer

When MIND is weak situation is a PROBLEM, when MIND is balanced situation is CHALLENGE, when MIND is strong situation is an OPPORTUNITY 😉
 

Facebook Search Users with Email and Save to Database


Hits: 2290  

Search Facebook Users in Facebook website and save to any external database (text, csv, json, xml etc.)……

How to check Facebook Application is Alive or Dead?


Hits: 2631  
<?php

include("facebook.php");

$APPLICATION_ID = "";
$APPLICATION_SECRET = "";

$facebook = new Facebook(array(
'appId'  => $APPLICATION_ID,
'secret' => $APPLICATION_SECRET,
'cookie' => true
));

$fql    =   "SELECT api_key FROM application WHERE app_id=" . $APPLICATION_ID;
$param  =   array(
 'method'    => 'fql.query',
 'query'     => $fql,
 'callback'  => ''
);

$fqlResult   =   $facebook->api($param);

if(isset($fqlResult[0]['api_key']) && $fqlResult[0]['api_key']!="")
  echo "This app is Alive!";
else
  echo "This app is Dead!";

?>

Image Map in FBML


Hits: 2319  

Facebook FBML application does not support hotspots in an image map using dreamweaver.

<div style="position: relative;">
<!-- Hot Spots - Image Map -->
<div id="svnlabs1" style="background: none repeat scroll 0% 0% transparent; cursor: pointer; outline: medium none; text-align: center; vertical-align: middle; position: absolute; top: 72px; left: 460px; z-index: 99; padding: 10px;"></div>
<div id="svnlabs2" style="background: none repeat scroll 0% 0% transparent; cursor: pointer; outline: medium none; text-align: center; vertical-align: middle; position: absolute; top: 11px; left: 635px; z-index: 99; padding: 10px;"></div>
<div id="svnlabs3" style="background: none repeat scroll 0% 0% transparent; cursor: pointer; outline: medium none; text-align: center; vertical-align: middle; position: absolute; top: 170px; left: 632px; z-index: 99; padding: 10px;"></div>
<div id="svnlabs4" style="background: none repeat scroll 0% 0% transparent; cursor: pointer; outline: medium none; text-align: center; vertical-align: middle; position: absolute; top: 78px; left: 887px; z-index: 99; padding: 10px;"></div>
<!-- Main Image -->
<img src="http://blog.svnlabs.com/wp-content/uploads/2009/06/svnlabs.jpg" border="0" alt="" align="absbottom" /></div>

We can use above code to map image using DIV elements on main image.
It is quite useful to insert hotspots on Images in FBML 😉

Maturity is not when we start speaking BIG things But..Actually it is, When we start understanding small things.