Skip to content

Instantly share code, notes, and snippets.

@macchandev
Forked from tuanxuong/index.php
Created February 14, 2017 10:19
Show Gist options
  • Save macchandev/97c29596f94f6a0314548004579978d7 to your computer and use it in GitHub Desktop.
Save macchandev/97c29596f94f6a0314548004579978d7 to your computer and use it in GitHub Desktop.
Update Status Follow LIKE,LOVE
<?php
header("Refresh:120");
date_default_timezone_set('asia/ho_chi_minh');
$id = ''; // ID post Status mới nhất
$facebook_access_token=''; // Token full quyền
// -- Bắt đầu -- Đoạn dưới đây dùng để đếm LẤY REACTION MỚI NHẤT
$url = 'https://graph.facebook.com/v2.8/?ids='.$id.'&fields=reactions.limit(1)&access_token='.$facebook_access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
$name = $obj->$id->reactions->data[0]->name; //Trả ra Tên
$type = $obj->$id->reactions->data[0]->type; // Trả ra Reaction
$time = date("d-m-y h:i:s"); // Trả ra Thời gian hiện tại
// -- Kết thúc --
echo $status =
"Cảm ơn bạn $name. Bạn ấy là người $type mới nhất.
Status cập nhật lần cuối lúc $time"
;// Đây sẽ là phần nội dung cập nhật trên Status mới nhất.
//return;
// -- Bắt đầu -- Đoạn dưới đây dùng để cập nhật status trên FB. Không sửa đoạn này.
$params = array('access_token'=>$facebook_access_token, 'message'=>$status);
$url = "https://graph.facebook.com/".$id;
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));
$result = curl_exec($ch);
// -- Kết thúc --
var_dump($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment