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;

$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(),

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){

$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);


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,
echo "<script type="text/javascript">
top.location.href = '
// ]]></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:


//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
//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

Tuesday, February 21, 2012


Here's how you execute a POST using the PHP CURL library.

//define post values 
$message="test message ";//define post url
$url="http://localhost/WebServices/";//encode the message
$message urlencode($message);//initialize the curl
$ch curl_init();

 if (!
"Couldn't initialize a cURL handle");
//setting options
$ret curl_setopt($chCURLOPT_URL,$url);
curl_setopt ($chCURLOPT_POST1);
curl_setopt($chCURLOPT_SSL_VERIFYHOST2);//setup post fields
curl_setopt ($chCURLOPT_POSTFIELDS,"Message=$message");
$ret curl_setopt($chCURLOPT_RETURNTRANSFER1);//If you are behind proxy then please uncomment below line and provide your proxy ip with port.
// $ret = curl_setopt($ch, CURLOPT_PROXY, "PROXY IP ADDRESS:PORT");

//execute and geting response
$curlresponse curl_exec($ch);

'curl error : 'curl_error($ch);

 if (empty(
$ret)) {
// some kind of an error happened
curl_close($ch); // close cURL handler
} else {
$info curl_getinfo($ch);
curl_close($ch); // close cURL handler
    //echo "<br>";
echo $curlresponse;    //echo "post message Sent Succesfully" ;

Email Script in PHP

Below script is simple email script in php. by using mail function

// Email destination address
 $to 'to@email.com'; 
// Email Subject
 $subject 'PHP Simple Mailer Example'; 
// Email message 
$content 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
 Etiam sit amet elit vitae arcu interdum ullamcorper.'; 
// Additional headers

$headers  'MIME-Version: 1.0' "\n";
$headers .= 'Content-type: text; charset=iso-8859-1' "\n"; 
$headers .= 'From: from@email.com';


Thursday, February 16, 2012

codeigniter error reporting handling

1. Turn off PHP Errors with error_reporting(0)In the root directory of your CodeIgniter installthere is an index.php fileThe first option in there is ‘PHP ERROR REPORTING LEVEL’.

 Set it to zero:error_reporting(0);CodeIgniter version 2.0.1 and above have an environment constant in the index.php file as wellSetting this to “production” will disable all PHP error outputRead more about this on the Codeigniter User Guide page on Security and on Handling Environments. 

2. Turn off Database Errors in Config
The PHP errors are off
but any MySQL errors are still going to showTurn these off in the /config/database.php fileSet the db_debug option to false: 

$db['default']['db_debug'] = FALSE; 

3. Adjust Error Logging Threshold
/config/config.php file has a log threshold optionIt states “For a live site you’ll usually only enable Errors (1to be logged otherwise your log files will fill up very fast.

['log_threshold'] = 1; 

4. Turn on all Errors in Config
In the root directory of your CodeIgniter install
there is an index.php fileThe first option in there is ‘PHP ERROR REPORTING LEVEL’Set it to :