Add/Invite Users to a Facebook group using Facebook Graph API - facebook

I've got an iOS app using Corona(ie. in LUA; not ObjectiveC; though I'm not requesting specific Corona help, just how to do this in general) that I want to add or invite users of the app to the Facebook group. I've had success with members of the group posting to the group's wall from my app, but can't for the life of me get the "Invite Users" bit of code to work for people who aren't yet members of the FB group.
All of the posts on this website say it either can't be done (presumably because they're from before the Groups API was available) or just repeat what the Facebook documentation says (which I've read a million times, but maybe don't fully understand).
From Facebook's Group documentation (https://developers.facebook.com/docs/reference/api/group/)...
"Applications can invite users to a group by issuing a POST request to /GROUP_ID/members/USER_ID with an app access_token."
After figuring out how to get the app access_token (as opposed to the user access_token), I've tried using 3 different methods to test this out; Corona's facebook API request() command, making a PHP page with the command, and even tried Facebook Graph Explorer to try this code and nothing works.
All of them along the lines of...
https://graph.facebook.com/myGroupID/members/nonMemberFBUserID?access_token=myAppsAppToken
Corona gives me an HTTP 200(which should mean OK) but the facebook request returns an error (I've got a question in their forum, but I don't often get much help from them). My website PHP page returns an empty data object ala: "{\"data\":[]}". And the Facebook Graph Explorer just lists all of the existing members along with some cryptic "paging" object with a "next" web address in it. If I go to this address directly, it says:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
But I passed an access_token as a parameter! Does this mean I also need to pass a user access_token? And if so, what do I call it, if the access_token variable is already used for the app's access_token?

The reason why you are getting an empty json object is because you are doing a GET request. if you change it to a POST request it should work.

Related

Facebook Graph API not returning regionalized pages when using App Token

We have a server application monitoring certain Facebook pages for Videos being uploaded. As there is no user involved (server app only), we use an App-Token for our requests.
So far so good, but we have issues with Pages that are only available in certain countries or territories, e.g. "/bitburger" seems to be available in Germany only. I can access the page via API with an User Token (relating to a german user), but my server or even the graph/api explorer (authenticating with an App Token) cannot access the page info.
It will result in an error such as:
{
"error": {
"message": "Unsupported get request. Object with ID 'bitburger' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "AlDpyo1BjLm"
}
}
Our application is supposed to be global solution that does not care about "regionalized pages" and needs to get the page info (and its published videos) independently from a users location.
Is there any way to achieve this?
So is there a possibility to tell the API-call to ignore regionalized filtering?
User Tokens are not an option (as I said, server app only) and we cannot have a user for every country in the world. We wouldn't even know the right country to begin with :/ It has to work with a location-independant App Token.
Thanks in advance for your help!
Looking forward to any solution.
Thanks and kind regards,
Daniel
// Update:
Thanks for your responses!
I got in touch with Facebook and it is in fact due to "market sites" that only users from this market (country or whatever) have access to. This maps to the API as well and teh App itself does not relate to any market.
The only solution there is (when not having a user to request with), is to get access for your App granted by the page admin. Then you can access the pages info. Unfortunately that does not help for anonymous monitoring.

Azure Logic apps Facebook connector gives empty response

When I try to use the Facebook connector in Azure logic apps I can't seem to get the "Get user timeline" to work.
I know for a fact that the User ID is valid (I checked using this URL: https://www.facebook.com/profile.php?id=). I also know for sure that the user has posts on it's timeline. I also tried multiple user ID's.
When I open the failed request in the Logic app I get this, the response is empty every time.
Is this related to privacy settings? Why doesn't this work?
We should probably retire/remove that operation. It is not possible to retrieve the post from Facebook graph API for another user's timeline. It used to so that is why it is there. Specifically, this post might be helpful: Facebook Graph API {user-id}/feed from others empty
The connector calls the /{user-id}/feed API. You can try out the behavior in the Facebook Graph explorer as well. https://developers.facebook.com/tools/explorer/

do I always need an access token to make a request with the Facebook Graph API?

The question raises because I was reading a book about Facebook Application development and when it explains how to make call to the graph, it says that I can verifiy how simply I can retrieve informations from the graph just writitng https://graph.facebook.com/myProfileId in my web browser. Well, I do that but I get this
{
"error": {
"message": "(#803) Cannot query users by their username (myusername)",
"type": "OAuthException",
"code": 803
}
}
but then if I include in the url an access token generated from the Graph API explorer, I can see the JSON with more informations, as I expected to be.
The question is: do I always need an access token to make a request with the Facebook Graph API even if the informations that I want to access are public? In case of affirmative answer to this question, why the book I'm reading says I can get informations from the graph even without an access token? Maybe this is a feature of an older version of the graph api?
Of course you need a token, the token is intrinsically linked to a specific user.
How could you retreive any informations (even public) with only a generic Url,
you must add to the request an information to identify the user that you want.
Personally I use this link "https://graph.facebook.com/me?access_token=" from the facebook doc : https://developers.facebook.com/docs/graph-api/overview

List of shares in FB graph api

I am trying to get a list of all users who share a given object on Facebook using the graph api.
There's been some useful info in this regard on stack exchange, here: Getting which users shared a post and here: List of people who shared on facebook
I experimented with the graph api's /{object-id}/sharedposts endpoint on the api. When I make the api call with a given object id which I have verified has been shared over 100 times (according to the /{page-id}/feed endopoint I am getting the object id from for said post), the api result invariably returns as such:
{
"data": [
]
}
So I am getting an empty array...is this because my access token will not allow me to get this information? I am not friends with any of the users sharing the post nor have I 'liked' the page in which the post originates from.
Just wondering if this is an authentication issue or if there's a different problem that I am running into. I've tried it with a few object IDs so I would like to ascertain exactly why there is no data when I use the /{object-id}/sharedposts endpoint.
Thanks!
There was a comment recently added to a response on the List of people who shared on Facebook post you referenced that solved this issue for me.
An access token with read_stream permissions is required, even if you have other permissions like read_insights. I was getting the same results as you until I added the read_stream permission.
However, you still may not get all or any of the shared posts. To see a share, it either has to be shared publicly or you must have permission to view that person's shared post.

Default FB search

I read documentation about FB API, and FB graph, and still not sure how to do something.
I'm creating unique client for FB and G+, and when i log in with some user (with no friends for example) I need to make default search, and to try to add friend.
However, when i do any kind of FQL search, i receive almost empty results, with no publicly shown data that i receive when i use FB mobile application, or just when i try to find someone on FB. Is there any chance to do that, and what kind of token i need to have.
It would be silly to create FB application, and wait for users to approve permissions for me, so later I can search for them, and add them as friends or so...
Is there any example, or any suggestion how to do that, i searched, and searched, and still nothing :(
Thanks in advance
Edit:
Well, i'm trying to use Graph API (i don't know if i can use any other).
I want to create application that i will be able to use as same application for facebook and google social network. So i need to login, and than to search for people (like in regular FB), and to add them as friends etc.
So, i'm trying to search for people with given string (i know that), to find info about user (i need permission and token, even if those info is public, or in other words, user needs to authorize my application, so i can later allow people who use my app to search for user, and have public info)
So, my question is, if there is any way to search user and his public info, available on FB application on mobile devices ?
Go to http://developers.facebook.com/docs/reference/api/ and CTRL+F for Searching section. You can use that to search for Facebook users.
But, as you said, you won't have the current user access_token, so you won't be able to perform the search. And if you try to use /search with an app access_token the response message is:
{
"error": {
"type": "OAuthException",
"message": "A user access token is required to request this resource."
}
}
So you need to create a Facebook App and get user permissions to perform the searches you want.