Find Number of Likes on Your Facebook Page with PHP

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

Go to https://developers.facebook.com/

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 

<?php

function Facebook_Page_Likes($id, $appid, $appsecret)
{
    $json_url = 'https://graph.facebook.com/' . $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;
    }

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

?>

How to Send SMS and Email Using PHP?

SMS
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: https://www.textlocal.in/
kapsystem: https://kapsystem.com/ 
msg91: https://msg91.com/
<?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 = "http://api.msg91.com/api/sendhttp.php"; $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; ?>
EMAIL
mail() is a predefined function in php and this is the simplest way
to send mail using php.
<?php
//message
$msg = "Hello World";

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

// send email
mail("someone@example.com","My subject",$msg);
?>

Labels

php (35) javascript (31) phpjavascript (30) jquery (23) html (20) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Popular Posts