I am trying to get the number of friends for a userid, I can see that this userid is a friend but how do I get there total number of friends?
I have tried using the /{user-id}/friends endpoint but I get a privilege error. Using /{user-id-a}/friends/{user-id-b} I just get my friend data.
You need to use /{user_id}/friends. Therefore you need to gather the user_friends permission during the login dialog of your app.
See
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends/
The response for the call will contain a field summary.total_count with the total number of friends this user_id has. Keep in mind that only the friends which are also using the same app will be returned in the friends data array. If you just want the total count, the info returned should be sufficient.
Related
I'm trying to get Pages liked by the user ordered descending by amount of likes each Page has...
It's difficult to get this using Graph API cause I'd have to fetch request like this:
let request = FBSDKGraphRequest(graphPath: "me/likes" parameters: nil)
and recursively call this inside because this request will paginate response. After I get everything I'll have to sort it locally and that's how I'd get it đŹ
IMHO, it's a lil bit overkill so I've looked into a method of achieving same thing but using FQL and this is the query:
SELECT name, fan_count FROM page WHERE page_id IN (SELECT page_id FROM page_fan WHERE uid = me()) ORDER BY fan_count DESC
At first I was happy with this but after some test my friend told me that he can't see Messi on his list. So I wonder what's the reason that not all Pages are show in this FQL query result?
You donât have to make separate requests for this.
The Graph API has a feature called âfield expansionâ, that allows you to specify that you want data from multiple âlevelsâ in one go. https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#fieldexpansion
So requesting
/me/likes?fields=id,name,likes
will give you the id, name and number of likes for each of the userâs liked pages.
(You will still have to follow the pagination links, gather all results and do the sorting on your end afterwards, since the API doesnât currently allow for sorting.)
FQL is deprecated and only works with older Apps using v2.0 of the Graph API. As of now, the only way to do this is to recursively get all Pages and do the sorting on your own.
the users active/away status does not appear to be listed here:
https://api.slack.com/types/user
is there another method to query this information that I missed?
Maybe you noticed it by now, but there is a method named users.getPresence in the Slack API.
Example of querying the API, given that you have created a token (token=xoxp-313xxxxxx-313xxxxxx-313xxxxxx-xxxxxx) and you are looking for the user with the ID U03xxxxxx.
curl -X POST https://slack.com/api/users.getPresence
--data "token=xoxp-313xxxxxx-313xxxxxx-313xxxxxx-xxxxxx&user=U03xxxxxx"
Response:
{"ok":true,"presence":"away"}
Note that you can get user ids, with the method users.list or users.info.
REF: https://api.slack.com/methods
Currently there's the status key on user objects returned from
https://slack.com/api/users.info
I think the most easier way for this > get all user presence status (up to 1000 users) quickly is the users.list method.
https://api.slack.com/methods/users.info
https://slack.com/api/users.list?token=xoxp-173888888-XXXXXXXX-YYYYYYYY-ZZZZZZZZ&presence=true&pretty=1
Please don't forget to read the documentation, sometimes the limit at 200.
1.2.GA and Android Emulator to run my Apps. AM using codebird to authorize my app in twitter and I got access token and using it how to get screen name or userid to fetch tweets of the user?
When the user returns from the authentication screen, you need to trade
the obtained request token for an access token, using the OAuth verifier.
As discussed in the README section âUsage example,â you use a call to
oauth/access_token to do that.
The API reply to this method call tells you details about the user that just logged in.
These details contain the user ID and the screen name.
Take a look at the returned data as follows:
{
oauth_token: "14648265-rPn8EJwfB**********************",
oauth_token_secret: "agvf3L3**************************",
user_id: 14648265,
screen_name: "myx",
httpstatus: 200
}
If you need to get more details, such as the userâs latest tweet,
you should fetch the complete User Entity. The simplest way to get the
user entity of the currently authenticated user is to use the
account/verify_credentials API method. In Codebird, it works like this:
cb.__call(
"account_verifyCredentials",
{},
function (reply) {
console.log(reply);
}
);
I suggest to cache the User Entity after obtaining it, as the
account/verify_credentials method is rate-limited by 15 calls per 15 minutes.
I am new to the Twitter API and I'm having an issue with the user_timeline API.
I am using the following REST query:
https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=twitterapi&count=50
which is provides the user's timeline data, however it only gives the user's tweets; I want all tweets by and about the user (i.e. the user's tweets, and mentions of the user by the user's followers).
Thanks in advance!
You can access this by searching for the user's # handle. This will return tweets which mention #user and also tweets by #user.
Twitter API - Search
--
I've no experience about formatting for JSON calls but the following should be enough:
https://api.twitter.com/1.1/search/tweets.json?q=%40ataulm
The %40 is for the # symbol, and ataulm is the user name you wish to query. See the page linked for default values to the other parameters - this will, for example, only return 15 tweets per "page" (not sure what a page refers to), but can be set to a maximum of 100 per page, using the count parameter.
"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500'
BUt it is giving only 200 records.
I am creating a Facebook app and need to access people's ages - only the friends of the user, not the general public.
I am using rFacebook version 0.6.2, setup along the line of this.
I need to get the ages/ birthdays of all of my friends.
As per http://rfacebook.rubyforge.org/ rFacebook isnt being maintained, it suggested Facebooker, but even Facebooker hasn't been updated in months: https://github.com/mmangino/facebooker
I suggest Koala (and not just because I'm an Aussie). Have a read at: https://github.com/arsduo/koala There's also details on setting Koala up on Rails: https://github.com/arsduo/koala/wiki/Koala-on-Rails
I just built a FB app using Koala and a Custom Tab Page last week and it was very quick.
You also need to read: http://developers.facebook.com/docs/authentication/ (pay attention to the mention of scopes and permission levels). As per: http://developers.facebook.com/docs/authentication/permissions/ you must request 'friends_birthday' when you request your scope.
I'm not sure there is an easy way to get all your friends' birthdays in a batch. You might have to traverse each friend and get their info.
As a test, go to: http://developers.facebook.com/docs/reference/api/ and click on the friends link. Then copy the ID of your first friend. In the URL replace '/me/friends' with the ID you copied. Eg: https://graph.facebook.com/me/friends?access_token=ABC123 becomes https://graph.facebook.com/12345678?access_token=ABC123 You will then see the data of that friend, one field of which is birthday.
#i have already asked for user permissions, and have my access token
#https://github.com/arsduo/koala/wiki/OAuth
graph = Koala::Facebook::GraphAPI.new(oauth_access_token)
friends = graph.get_connections("me", "friends")
friends.each do |f|
friend = graph.get_object(f['id'])
puts "#{f['name']} has a birthday on #{friend["birthday"]}"
end
Although, you might be able to use FQL to do a batch.
#FQL taken from http://stackoverflow.com/questions/5063431/easiest-way-to-get-birthday-info-of-all-friends-thorugh-graph-api
fql = "select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me())"
#https://github.com/arsduo/koala/wiki/REST-API
#rest = Koala::Facebook::GraphAndRestAPI.new(oauth_access_token)
birthdays = #rest.fql_query(fql)
Good luck!
FQL is probably the way to go here as is mentioned above.
A couple notes:
Not all of your friends will have a birthday accessible (either because they restricted that information, or because they didn't post it). If you only want data for your friends with accessible birthdays, you can add a "and birthday_date" to your where clause.
That query will not return all data, but only the first 100 or so. If you want to get all of them, you will need to request them one page at a time. You can do this by adding a "limit 0,50" clause, to request 50 rows, starting at the 0th one.