2012-03-01 35 views

Trả lời

3

Tôi nghĩ bạn nên sử dụng thông báo FQL.
Nhưng thông báo thực sự bị giới hạn trong 7 ngày qua.

Hãy thử truy vấn này:

SELECT created_time, sender_id, title_html, href, object_type 
FROM notification 
WHERE recipient_id=me() and object_type = 'friend' 

Cập nhật:

cách tiếp cận khác, một chút khéo léo.
Bạn sẽ có thể có một cái nhìn tại tình bạn cũ vào stream của bạn:

SELECT created_time, description FROM stream WHERE source_id = me() 
and (strpos(lower(description),'are now friends') > 0 
    or strpos(lower(description),'is now friends') > 0) 
limit 50 

Bằng cách này bạn sẽ có được tất cả các hàng có chứa các câu are now friends hoặc is now friends, (lưu ý rằng câu chữ phụ thuộc từ khách hàng() locale? cài đặt). Vì vậy, bạn sẽ phù hợp với tất cả các hàng:

  • X và Y là bạn bè
  • X bây giờ là bạn bè với X và Y ...

Mỗi truy vấn của bảng suối bị hạn chế đến 30 ngày trước hoặc 50 bài đăng, tùy theo mức nào lớn hơn, tuy nhiên bạn có thể sử dụng các trường thời gian cụ thể như created_time cùng với toán tử FQL (chẳng hạn như < hoặc>) để truy xuất phạm vi bài đăng lớn hơn nhiều. https://developers.facebook.com/docs/reference/fql/stream/

Cập nhật 2:

Nếu bạn muốn sử dụng chỉ graph api, như xa Tôi biết bạn có cùng giới hạn của FQL (ví dụ: bạn bị giới hạn kéo dài 7 ngày).

https://graph.facebook.com/me/notifications?include_read=1

Nhưng trường hợp này, bạn không thể lọc cho object_type và bạn phải tìm tất cả title containings "accepted your friend request"

+0

Chúng tôi đang sử dụng graph api, Bất kỳ ý tưởng? – PrateekSaluja

+0

Bạn đã thử https://graph.facebook.com/me/notifications?include_read=1 chưa – freedev

0
try this.. 
$count=0; 
$fbid=xxxxx; 
$onemonthbefore = strtotime(date("Y-m-d",strtotime("-1 Months"))); 
$ss=urlencode("SELECT created_time,description_tags,source_id,description FROM  stream WHERE source_id = xxxxxx and (strpos(lower(description),'are now friends') > 0 or strpos(lower(description),'is now friends') > 0) limit 100"); 
$sql="https://graph.facebook.com/fql?q=$ss&access_token=xxxxxxxxx&format=json& date_format=U"; 
$new =file_get_contents($sql); 
$new =json_decode($new); 
foreach ($new->data as $data) 
{ 
    if($data->created_time > $onemonthbefore) 
    { 
    foreach ($data->description_tags as $tags) 
    { 

    foreach ($tags as $friend) 
    { 
    if($friend->id !=$fbid) 
     { 
     $count++; 
     } 
    } 
} 
} 
} 
echo "new friends=".$count; 
Các vấn đề liên quan