File: /var/www/nclive/backend/share_status_exam_page.php
<?php
include "config.php";
function curl_get_shares( $url ){
$access_token = '1686126744757445|47d6a4141824641cb7c30d6079405806';
$api_url = 'https://graph.facebook.com/v3.0/?id=' . urlencode( $url ) . '&fields=engagement&access_token=' . $access_token;
$fb_connect = curl_init(); // initializing
curl_setopt( $fb_connect, CURLOPT_URL, $api_url );
curl_setopt( $fb_connect, CURLOPT_RETURNTRANSFER, 1 ); // return the result, do not print
curl_setopt( $fb_connect, CURLOPT_TIMEOUT, 20 );
$json_return = curl_exec( $fb_connect ); // connect and get json data
curl_close( $fb_connect ); // close connection
$body = json_decode( $json_return );
return intval( $body->engagement->share_count );
}
$limit = 10;
$pageNo = isset($_GET['pageN']) ? $_GET['pageN'] : 1;
$indexN = ($pageNo - 1) * $limit;
$getLinksQuery = "select se.url_slug from sp_exam as se where se.status!='0' order by se.exam_id desc limit $indexN, $limit";
$sqlLinksQuery=$db->prepare($getLinksQuery);
$sqlLinksQuery->execute();
?>
<script src="../assets/js/jquery-2.1.1.js"></script>
<script type="text/javascript" charset="utf8" src="../assets/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="../assets/js/dataTables.responsive.min.js"></script>
<link rel="stylesheet" href="../assets/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="../assets/css/responsive.dataTables.min.css">
<script>
jQuery.noConflict();
jQuery(function($) {
jQuery('#board_exam').dataTable({
"processing": true,
"responsive": true,
"order": [
[0, 'asc']
],
"bPaginate": true,
});
});
</script>
<div class="row">
<div class="col-lg-12">
<h2 class="content-heading">Exam Wise Share Count</h2>
<div class="table-responsive">
<table id="board_exam" class="table table-striped table-bordered dt-responsive nowrap" style="width: 100%; cellspacing: 0;">
<thead>
<tr>
<th>S.No</th>
<th>URL</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
while($rowLQ=$sqlLinksQuery->fetch()){
$indx = $i+$indexN;
$examUrl = "http://naukriconnect.com/exam-details/".$rowLQ['url_slug']."/";
$shareCount = curl_get_shares($examUrl);
//echo "<br>".$indx."-".$examUrl."-".$shareCount;
?>
<tr>
<td><?php echo $indx; ?></td>
<td><?php echo $examUrl; ?></td>
<td><?php echo $shareCount; ?></td>
</tr>
<?php $i++; } ?>
</tbody>
</table>
</div>
</div>
</div>