Created
February 14, 2017 09:00
-
-
Save tuanxuong/68dfa19cfd0be051534d2367597237e9 to your computer and use it in GitHub Desktop.
Update Status Follow LIKE,LOVE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
?> |
Chỉnh thời điểm status kết thúc ở dòng nào ạ. Ngoài ra có thể thêm các khung thời điểm khác nhau để hiện các phần khác nhau không ạ
@leanhboi1999 bạn có thể thêm for hay while và 1 phép toán tử để quyết định số lần hay dùng while $time <> dd-mm-yyyy ... để xác định thời gian dừng
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
anh yêu em nhiều lắm <3