Wrong number of Facebook likes via Facebook Graph API
I'm running a Wordpress blog and using default facebook like buttons on single post templates.
<fb:like href="<?php echo get_permalink(); ?>" send="false" width="80" height="20" layout="button_count" show_faces="false" font="arial"></fb:like>
The number on these buttons is displayed correctly.
I'm also saving the facebook count number to post meta data by passing the link to the Graph API:
'http://graph.facebook.com/?ids=' . get_permalink()
This was OK, but recently I've noticed that the like number is no longer saved to the post meta data. Though the number on the like button is displayed correctly.
In order to check why the number is no longer saved to the post meta data, I opened
http://graph.facebook.com/?ids=http://blog.com/2011/07/04/post-name/
in my browser. Here's the result:
{
"http://blog.com/2011/07/04/post-name/": {
"id": "284885928194873",
"name": "Post Name",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276621_284885928194893_1295441978_s.jpg",
"link": "http://blog.com/2011/07/04/post-name/",
"likes": 1,
"category": "Personal blog",
"description": "Post Description",
"parking": {
"street": 0,
"lot": 0,
"valet": 0
},
"hours": {
"mon_1_open": 0,
"mon_1_close": 0,
"tue_1_open": 0,
"tue_1_close": 0,
"wed_1_open": 0,
"wed_1_close": 0,
"thu_1_open": 0,
"thu_1_close": 0,
"fri_1_open": 0,
"fri_1_close": 0,
"sat_1_open": 0,
"sat_1_close": 0,
"sun_1_open": 0,
"sun_1_close": 0,
"mon_2_open": 0,
"mon_2_close": 0,
"tue_2_open": 0,
"tue_2_close": 0,
"wed_2_open": 0,
"wed_2_close"开发者_StackOverflow中文版: 0,
"thu_2_open": 0,
"thu_2_close": 0,
"fri_2_open": 0,
"fri_2_close": 0,
"sat_2_open": 0,
"sat_2_close": 0,
"sun_2_open": 0,
"sun_2_close": 0
},
"payment_options": {
"cash_only": 0,
"visa": 0,
"amex": 0,
"mastercard": 0,
"discover": 0
},
"restaurant_services": {
"reserve": 0,
"walkins": 0,
"groups": 0,
"kids": 0,
"takeout": 0,
"delivery": 0,
"catering": 0,
"waiter": 0,
"outdoor": 0
},
"restaurant_specialties": {
"breakfast": 0,
"lunch": 0,
"dinner": 0,
"coffee": 0,
"drinks": 0
},
"can_post": true
}
}
I have never received such result. I do not know what parking
or restaurant_specialties
are doing here.
However when passing the same post URL but with www
:
http://graph.facebook.com/?ids=http://www.blog.com/2011/07/04/post-name/
I get what there actually should be:
{
"http://www.blog.com/2011/07/04/post-name/": {
"id": "http://www.blog.com/2011/07/04/post-name/",
"shares": 4
}
}
Is there something wrong with Facebook? What can I do so that I can keep on saving the Facebook like number to the post meta data as I used to do it?
Since id serves as identifying key for your page, it matters whether there is or isn't www
.
You must use the identical permalink that you used to create the like button, I believe.
精彩评论