webhost

Web hosting

Wednesday, March 28, 2012

Solution for facebook logouturl not working

we can get the user information,facebook loginUrl and logoutUrl from the below code using facebook SDK. but now the logoutUrl is not working in facebook by using below code 



$config = array(
            
'appId'  => '1234',
            
'secret' => '123456789','fileUpload' => true// Indicates if the CURL based @ syntax for file uploads is enabled. $user_id $facebook->getUser();
        
// We may or may not have this data based on whether the user is logged in.
        //
        // If we have a $user id here, it means we know the user is logged into
        // Facebook, but we don't know if the access token is valid. An access
        // token is invalid if the user logged out of Facebook.
$profile null;

if($user_id)
     {
    
$userInfos   $facebook->api('/'.$user);
            try {
                
// Proceed knowing you have a logged in user who's authenticated.
    
$profile $facebook->api('/me?fields=id,name,link,email');
                
$fql    =   "select name, location, sex, pic_square from user where uid=" $user;
            
$param  =   array(
                
'method'    => 'fql.query',
                
'query'     => $fql,
                
'callback'  => ''
            
);
  
$fb_data = array(
                  
'me' => $profile,
                  
'uid' => $user_id,
                  
'loginUrl' => $facebook->getLoginUrl(),
                  
'logoutUrl' => $facebook->getLogoutUrl(),
                    );
                    <
del></del>print_r($fb_data); 




The above fetch logourUrl is not working

if try below code ie to find facebook logoutUrl separate. its a valid logoutUrl its working for me






function get_logout_url(){//return the facebook logoutUrl

    
return  $facebook->getLogoutUrl();








Sunday, March 25, 2012

facebook FQL multi Query using graph api

Facebook has a SQL like query language, FQL,  which allows you to request various data points about your pages, applications, etc. When you need a single data point like your page's total fans, you make a call to the method, fql.query to get your data. For a single data point this is great, but what if you are building a chart and need more than one data point? Making repeated calls to Facebook, will quickly begin to become tedious and slow. Luckily, Facebook has another method, fql.multi-query, which allows you to submit multiple queries at the same time and receive them back in a single result-set.

Friday, March 23, 2012

Facebook FQL query using graph api

we can run facebook FQL  query using the graph api.
Here example to get facebook photos from facebook album
First we need to include the facebook class then create an object of facebook class
by using a simple example of FQL query we get an array of details of photos of particular album

require '../src/facebook.php';

 $facebook = new Facebook(array(
  
'appId'  => '...',
  
'secret' => '...'));

function get_photos_by_album_id($album_id){

if(
$album_id)
        
$fql            =   'SELECT pid,src_big,owner,link,position,created,caption,src FROM photo WHERE aid="'.$album_id.'"';
           
                
$param  =   array(
                
'method'    => 'fql.query',
                
'query'     => $fql,
                
'callback'  => ''
            
);
            
$fqlResult   =   $facebook->api($param);
    return 
$fqlResult;

}

Wednesday, March 21, 2012

Create photo albums and upload photos using the Facebook

By using Facebook graph API allow us to access public information like user's first name, last name and profile picture are publicly available. To get additional access like upload photos,create albums,you must first get their permission.

The code example assumes that you have already generated an authenticated session while generating the loginUrl we need to specify scope for the permission (photo_upload, user_photos)

 require '../src/facebook.php';$facebook = new Facebook(array(
  
'appId'  => '...',
  
'secret' => '...'));$loginUrl=$facebook->getLoginUrl( array(
                
'scope'         'email,
                                   publish_stream,
                                   user_birthday,
                                   read_stream,
                                   photo_upload,
                                   user_photos,
                                   user_photo_video_tags,
                                 );
echo "<script type="text/javascript">
top.location.href = '
$loginUrl';
// ]]></script>";?>

 
 permission popup once we get the permission from user we can able to upload the photos to there albums

The following snippet creates a photo album and then uploads a photo into it:

 <?php
$facebook->setFileUploadSupport(true);

//Create an album
$album_details = array(
        '
message'=> 'Album desc',
        '
name'=> 'Album name'
);
$create_album = $facebook->api('
/me/albums', 'post', $album_details);

//Get album ID of the album you'
ve just created
$album_uid 
$create_album['id'];
  
//Upload a photo to album of ID...$photo_details = array(
    
'message'=> 'Photo message');$file='app.jpg'//Example image file$photo_details['image'] = '@' realpath($file);
  
$upload_photo $facebook->api('/'.$album_uid.'/photos''post'$photo_details);?>



 Supported Image Types You can upload the following image file formats through this call: *GIF *JPG *PNG *PSD *TIFF *JP2 *IFF *WBMP *XBM Facebook SDK