Retrieving Facebook Page Statuses with PHP - php

Having trawled the web for days, I cannot find an up-to-date, working method to retrieve a list of the latest statuses on a Facebook page.
On the status section of the Graph API, I am greeted with "This document refers to a feature that was removed after Graph API v2.3"
I can't get file_get_contents to work on Facebook pages as I'm presented with a Captcha
It's for competitor research, I only actually want:
Post date
Number of Likes/Share/Replies
I couldn't care less for the status content itself, just the metrics around it.
A JSON object would be great, but I'll take anything at this stage.
Anyone else managed to get this sort of data or know a way to use file_get_contents on Facebook pages?
Thanks.

A status is just a certain kind of post – so all you need to do is request the page’s feed (resp. posts) instead, and then check if their type is status.
I've just tried to access the post object to get like/favourite counts .etc and get "[message] => (#12) singular statuses API is deprecated for versions v2.4 and higher"
You need to use the “full” post id as you get it from the /feed or /posts endpoint – the combination of page-id, underscore, post-id. (At least that’s the current format, but someone from Facebook told me we should not rely on that, it might change at some point. Best if you really just use the full id, as the endpoint returns it.)
And since you are interested in overall number of likes only, not the individual likes, you could make a request like this,
{full_post_id}?fields=likes.summary(1).limit(0)
That requests the summary (contains total counts), and limits the number of individual likes returned to zero (so as not to request any unnecessary data.) It works the same for comments. But I think for shared posts there is no such counts, you will only get a list of posts (which might not be all, but only those you are allowed to see.)

Related

Is there any way to get the number of FB users on a specific country?

I would like to know if is there any possible way to show the total number of users of a specific country in my webpage. As far as I found, you can not get it through API.
I'm guessing you really want the total number of users on facebook who have 'liked' or used facebooks oauth to connected with your site.
Do you use graph api in your site? I'm pretty sure you can query by country name--as long as the user's who have shared that info with you have provided it.
Check this out... http://developers.facebook.com/docs/reference/api/
And this: http://developers.facebook.com/docs/reference/api/insights/
From their site
Facebook Insights provides the ability to see geographic and
demographic data for people that have Liked a Page or installed an
app. Location data is based on the geographic location of each person
as determined by their browser IP address and is limited to the top 20
countries and cities. All other demographic information is aggregated
and non-personally identifiable.
Generic searches can be done like this:
https://graph.facebook.com/search?type=location&place=166793820034304
Where the place id is the id for whatever you want to search on.
https://graph.facebook.com/search?type=location&place=166793820034304
Disclamer: This method is not supported by Facebook. Use it at your own risk. I take no responsibility whatsoever.
Go to: https://www.facebook.com/ads/manage/adscreator/
Fill in the ad info with something random (eg. google.com as the url)
In the next part you'll notice a dynamic reach estimation that changes depending on the parameters you select, including country. Try changing the country and observe the network activity with for instance the developers tools of Google Chrome.
Call the ajax url that returns the json data with the proper parameters programatically, this should be easy to figure out in the previous step.
Collect and store the json data for your evil deeds.
???
PROFIT!
The actual ajax call and parameters change from time to time, which is why I didn't include them directly, but it should be easy enough to figure it all out. Also note that they are estimates, even if they come from Facebook, they don't count every single user every time an advertiser sets up an ad — it's the best estimate you can possibly get though.
This method as I mentioned is neither official nor supported by Facebook, but sites like socialbakers.com or checkfacebook.com have been using them for ages. (There, I revealed the secret)

LinkedIn API, Reading groups posts issue

I am using Zend Framework to access LinkedIn API.
When reading posts from a group (using http://api.linkedin.com/v1/groups/[group_id]/posts:(some_arguments) together with start and count) sometimes I can load only several first posts from first page. When trying to load next page I receive empty result, but sometimes it works fine .
I can see the issue only when trying to read popular groups. It always works correctly when reading my small group or my network.
Maybe somebody has seen this issue before and knows what to do?
Thank you.
Depending on what "some arguments" are and the number of posts you're requesting, you may be running into a timeout. If you're getting information about the profiles for the people who posted, commented and/or liked the posts as well as the post information itself, it can be an expensive call on the backend.
Try retrieving fewer posts at once, or reducing the number of additional fields you're requesting, and see if that resolves the problem. If it does, please post in the forum at developer.linkedin.com and let us know about the issue, so we can make sure the engineers are aware of the timeouts.

Is there any way to count the number of mentions made by a particular twitter id without authentication

Is there any way in php to find out the total number of mentions made by a particular twitter id.Suppose my Twitter Id is 123456789 or my screen name is "ABCD" . I want to calculate total number of mentions made by me(i.e. #andrew) so far.I want to do this without user authentication.
Thanks
Very well, both cases. In the case of finding out how often a certain user mentions others you could use the user_timeline resource without needing authentication. You could fetch 200 tweets by a user a time and then make use of the since_id parameter to keep fetching older tweets. For every tweet you can then check if it contains a mentions.
As for the other case, I'm not sure. You could use the search API with a search string of "to:username" for #replies or a search string of "username" which would yield tweets by that user, as well as #replies and #mentions. Twitter search only gives results for the last couple of days though so I doubt that this would help you.
Good luck!

Multiple twitter users' feed on one site without reaching the rate limit

I have a large number of twitter users I wish to sydicate onto a website using PHP and caching the tweets in MySQL. However I seem to be stumped by the rate-limit problem when ever I access the API. Every request I make to every user seems to count as a request, which stands to reason.
I notice other sites* doing this exact thing successfully. How are they getting around this, are they simply whitelisted, or is there a technique I'm missing?
*http://www.twackle.com/NFL/Aaron-Rodgers_1/tweets
The streaming API is what you are looking for, and more specifically, the filter method. Filter, at its least-privileged level, will allow you to follow 5,000 users in realtime, without them having to authorize your app, and you can track up to 400 keywords using this method as well.
Now, if you want historical tweets as well, you will have to pull those from the REST API (the streaming API's count parameter doesn't really help here), but since you can only retrieve the last 3200 tweets for a user via the REST API, you can pretty much backfill all available tweet history with 16 calls to statuses/user_timeline by passing in a count parameter value of 200 and paging accordingly.
http://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama&count=200&page=2
http://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama&count=200&page=3
http://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama&count=200&page=4
With your 350 calls per hour per single Twitter account, you could backfill approximately 22 full user timelines per hour.
On the implementation side, you'd probably be interested in Phirehose, a streaming API client interface for PHP.
try to auth first, before get the tweets. that should increase the rate limit
A simple method of combining multiple user_timelines is to create a Twitter list and use GET /:user/lists/:id/status. That single API request will return the most recent tweets from all users on the list.

Is there an API to determine the most common link in a number of tweets?

Is there an API (Twitter API does not provide this) that I can use to determine the most common links in 200 tweets for example. What I want to do is to get the latest 200 tweets and then determine what are people talking about, I am sure that the tweets will contain links (because I will ask the twitter API to return tweets that contain links only) but I will also want to make sure that my code will understand that Two URLs are the same even if they have different bit.ly links.
What I am trying to do (this might make it easier for your guys to provide some help) is that i am trying to determine what is the most important subject people are talking about in these 200 tweets. I understand that people might be talking about the same story but provide different links, however, i am not sure if there is an easy way to understand that.
Links to examples, APIs, sample code, and any other ideas will be helpful :)
If you need more information to explain this please tell me and I will edit the question to include more information
Not that I know of, but you can accomplish this by..
Find all of the links in the list of tweets using a regex pattern.
Use the twitter search api to search for each link. The number of results is returned.
Manually sort the links by # of results returned.
Fundamentally you can get this from the api, first get the latest public timeline (this will be 100 tweets, if you need 200 then you need to request a cursor and create a loop that checks if the next_cursor value is greater than 0) and then build a spider that determines relevancy.
http://api.twitter.com/1/statuses/public_timeline.???
where ??? is json, xml, rss or atom
If you want to determine the popularity of words then dump all the text into a string and then split it on spaces, punctuation etc, discard non-nouns, sort it and create a dictionary variable with the words and the count of the words.
If you want to determine the popularity of links then it is the same process but with an extra step to do a web request on each link to determine the ultimate link destination.
Building on what others say, you can use twitter search to get the tweets no problem and I wont go into that part in this answer.
A possible route for the short links:
You could, for example, goto bit.ly and create a custom short link for the url you are wanting to keep track of. Using that link if you add a + to the end of the url you will get link stats. example: http://bit.ly/tweelay+ Additionally, bit.ly keeps track of other short links that point to the same url. Which you could then use in your searches.
using bit.ly /stats API you can get a list of the shorten urls.
depending on the urls you are trying to keep track of you may have access to referral logs. (i.e. your own website) Using your referral log you may also be able to find additional short urls that you can use to search.

Categories