Chào các bạn hôm nay mình sẽ chia sẻ với các bạn mã nguồn PHP bật khiên avatar Facebook trực tiếp qua API gốc của Facebook . Bên đó dành cho những bạn không biết về code hay lười muốn sử dụng nhanh. Còn ở bài này mình share code api trực  tiếp của facebook không qua trung gian của ai cả.

Dưới đây là code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
echo batkhien($_GET['token']);
   function batkhien($token){
   $idfb = json_decode(file_get_contents("https://graph.facebook.com/me?access_token=".$token),true);
   if(empty($idfb['id']))
   {
   return "Token không hợp lệ";
   }
   else
   {
    $headers2 = array();
    $headers2[] = 'Authorization: OAuth '.$token;
    $data = 'variables={"0":{"is_shielded":true,"session_id":"9b78191c-84fd-4ab6-b0aa-19b39f04a6bc","actor_id":"'.$idfb['id'].'","client_mutation_id":"b0316dd6-3fd6-4beb-aed4-bb29c5dc64b0"}}&method=post&doc_id=1477043292367183&query_name=IsShieldedSetMutation&strip_defaults=true&strip_nulls=true&locale=en_US&client_country_code=US&fb_api_req_friendly_name=IsShieldedSetMutation&fb_api_caller_class=IsShieldedSetMutation';
    $c = curl_init();
    curl_setopt($c, CURLOPT_URL, "https://graph.facebook.com/graphql");
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($c, CURLOPT_SSL_VERIFYHOST,false);
    curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); 
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($c, CURLOPT_HTTPHEADER, $headers2);
    curl_setopt($c,CURLOPT_POST, 1);
    curl_setopt($c,CURLOPT_POSTFIELDS,$data);
    $page = curl_exec($c);
    curl_close($c);
    return "PuaruVN thành công";
}
}
?>
Trong đó:
  1. is_shielded:true là bật
  2. is_shielded:false là tắt
Share bởi Puaru – Vina4U