I have a custom post type called Neighborhoods, which stores information about various neighborhoods of a city. Each neighborhood also has a Facebook page. What I'd like to do is for each neighborhood, use the Facebook Graph to grab the number of likes of the page and save them in the WordPress database to display in various parts of my website.
I don't know exactly what code to use, but here is the basic outline:
Run this once a day:
Query neighborhood post type in the database
For each neighborhood:
$data = json_decode(file_get_contents('https://graph.facebook.com/neighborhoodURL'));
$numberOfLikes = $data->likes;
Save $numberOfLikes in it's own field in the database
And once that's set, I should be able to call the number of likes field in the loop.
Anyone know the best way to do this?