Friday, January 19, 2018

Find Number of Likes on Your Facebook Page with PHP

PHP code to find the number of likes on your facebook page.

Go to

Login with your Facebook username and password

Create an app from that you will get App ID and App Secret.

Use both of them in the program.

PHP Code 


function Facebook_Page_Likes($id, $appid, $appsecret)
    $json_url = '' . $id . '?access_token=' . $appid . '|' . $appsecret . '&fields=fan_count';
    $json = file_get_contents($json_url);

    $json_output = json_decode($json);

    if ($json_output->fan_count) {
        return $fan_count = $json_output->fan_count;
    } else {
        return 0;

Facebook_Page_Likes('XXXXX', 'APPID', 'APPSECRET');


How to Send SMS and Email Using PHP?

To send sms we need an API from the sms service provider. 
Here we are providing some of the sms service providers list.
Text Local:
<?php $authKey = "XXXXX"; //Your Authentkation key $mobileNumber = "9999999"; //Sender ID,While using route4 sender id should be 6 characters long. $senderId = "AAABBB"; $mymsg = "Hello world"; //Your message to send, Add URL encoding here. $message = urlencode("$mymsg"); $route = "default"; $postData = array( 'authkey' => $authKey, 'mobiles' => $mobileNumber, 'message' => $message, 'sender' => $senderId, 'route' => $route ); //API URL provided by your SMS service provider $url = ""; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData )); //Ignore SSL certificate verification curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $output = curl_exec($ch); if (curl_errno($ch)) { echo 'error:' . curl_error($ch); } curl_close($ch); echo $output; ?>
mail() is a predefined function in php and this is the simplest way
to send mail using php.
$msg = "Hello World";

// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);

// send email
mail("","My subject",$msg);