Facebook Messenger Web hooks Only Delivering for My Page - facebook

So I created a facebook "bot" which has pages_messaging permissions granted, I can run the following subscribe code successfully:
curl -i -X POST \
-d "access_token=PageTokenOfAnotherPage" \
"https://graph.facebook.com/v3.2/PageIDOfOtherPage/subscribed_apps?subscribed_fields=feed,mention,name,picture,category,description,conversations,branded_camera,feature_access_list,standby,messages,messaging_account_linking,messaging_checkout_updates,message_echoes,message_deliveries,messaging_game_plays,messaging_optins,messaging_optouts,messaging_payments,messaging_postbacks,messaging_pre_checkouts,message_reads,messaging_referrals,messaging_handovers,messaging_policy_enforcement,messaging_page_feedback,messaging_appointments,founded,company_overview,mission,products,general_info,leadgen,leadgen_fat,location,hours,parking,public_transit,page_about_story,phone,email,website,ratings,attire,payment_options,culinary_team,general_manager,price_range,awards,hometown,current_location,bio,affiliation,birthday,personal_info,personal_interests,publisher_subscriptions,members,checkins,page_upcoming_change,page_change_proposal,merchant_review,product_review,videos,live_videos,registration"
And I get back a 200 OK here with {"success":true} and when something other than a message happens, post, like, etc I get that back on my web hook, but not messages, what in the world am I doing wrong? Thanks!

So the answer to this one, was I forgot to add the pages_messaging in the oauth scope for the user token. Super important when you get the pages_messaging approved by Facebook be sure to go add it back into the scope.
Hope this helps someone else!

Related

Facebook Groups API: can't request advanced access

I created Facebook developer app to let my users posting to their Facebook pages/groups via API. I completed app review process for all required permission to be able to post on pages. But I am unable to request advanced access for Groups API which is required when I want to get my app approved for these 2 permissions: groups_access_member_info, publish_to_groups.
When I add these permissions and start the app review process it shows alert that I need to add Groups API as well. Full alert message: "You must also add Groups API to this submission before you can submit for review. You must also add Groups API to this submission before you can submit for review."
This error message is clear but the problem is button is grayed out so I can't add this permission for app review process:
It says I need to make a successful API call to groups endpoint to activate that button which I did already. I waited for a week after that API call but button is inactive still.
Requests I made to make that button active:
curl -i -X POST \
"https://graph.facebook.com/v15.0/[GROUP_ID]/feed?message=Hey&access_token=[REDACTED_ACCESS_TOKEN]"
curl -i -X GET \
"https://graph.facebook.com/v15.0/[GROUP_ID]/feed?access_token=[REDACTED_ACCESS_TOKEN]"
curl -i -X GET \
"https://graph.facebook.com/v15.0/[GROUP_FEED_ID]/?access_token=[REDACTED_ACCESS_TOKEN]"
All these three calls return successful repsonses (on development mode, of course).

Lacking permissions on a facebook API post

I'm trying to publish on a page throught FB API (with curl), I give this commande with post method to curl : https://graph.facebook.com/my_Page_Id/feed?message=Helloworld!&access_token=MY_PAGE_TOKEN
I get the following error code :
[message] => (#200) If posting to a group, requires app being installed in the group, and \
either publish_to_groups permission with user token, or both pages_read_engagement \
and pages_manage_posts permission with page token; If posting to a page, \
requires both pages_read_engagement and pages_manage_posts as an admin with \
sufficient administrative permission
[type] => OAuthException
[code] => 200
[fbtrace_id] => probably not necessary
)
If I entry this URL into my browser, i get an empty JSon string just like following. But the post isn't sent too.
{
"data": [
]
}
My app is not reviewed, but it still in dev mode. So if i understand the doc well, it's supposed to don't require these permissions...
My app is not reviewed, but it still in dev mode. So if i understand the doc well, it's supposed to don't require these permissions...
No, you did not understand that correctly.
This API call still needs the necessary permissions to be granted by the user (a page admin). This has nothing to do with dev vs live mode.
To be able to ask users for those permissions, when in live mode, you will need to submit your app for review and get it approved though.
And as long as you are in dev mode, any such posts you made via the API, will only be visible to people with a role in your app, they will be hidden from everyone else.

create fb user using fb api

I am building a facebook app and for that I need to create a fake fb user for each user that signs up into my app.
Is there an api available for creating facebook users?
Any help is appreciated.
For testing purpose you can create test user with API. The document is provided here. By specifying installed=true parameter, your app is authorized by default. It's just easy as below:
curl -X POST \
-d "installed=true" \
https://graph.facebook.com/{app-id}/accounts/test-users

Can I change a test user's password

Is it possible to change a test user's password so I can logon to any of my test users as normal so I can test my app properly?
I've tried :
https://graph.facebook.com/{user id}?password={newpassword}&method=post&access_token={the access token}
I got the access token from the Roles screen where all my test users are listed. The above link returns :
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException"
}
}
What am I doing wrong? And is there another way to change the password?
I have 15 or so test users and I need to be able to log in as any of them. Only my main test user is registered with my app, the others are friends of the main test user (this is by design)
I tried creating lots of normal users to test with and quickly realised Facebook do their best to stop people doing this
Thanks
Yes - You can. However I have tried only manually - it works.
You have to be admin of application for which users You are editing
Go to FB Developers page -> Click 'Edit Roles'
At the bottom of the page there will be all users listed, each having option to set password next to its profile photo. Just Click and change.
Hope that helps a bit. As it is not a solution to set manually password for 25 users. But if it is not possible to do it manually then it won't be possible with API. worth to try, just to identify error.
Yes - creating real users for testing purposes is not an option
This is very Easy by using even APP Dashboard as follow
All though you can use Graph API for the same ,with User APP Access Toke or User access Token (If user ID is accessed) for this Process
Here is Python script of the same
For some reason, Facebook's documentation says that you should do an HTTP POST, but the example they show uses a query string, not post data.
Try submitting all query parameters as post data:
curl -H "Content-Type: application/x-www-form-urlencoded" \
--data "access_token=<facebook app access token>&method=post&name=<full user name>&password=<password>" \
-X POST 'https://graph.facebook.com/<facebook test user id>'

How could I get access token for another user (from my app)?

I would like post some message as another user (not currently using the app). Is it possible? Of course, I would like use user which allow to get access my app.
When a user goes to your app, you can ask him for the extended permissions 'offline_access' and 'publish_stream'. With these permissions, you should be able to post as that user, even if he is not currently visiting the app.
More info about extended permissions can be found at http://developers.facebook.com/docs/authentication/permissions
edit:
You can publish to the Facebook graph
by issuing HTTP POST requests to the
appropriate connection URLs, using an
access token on behalf of the user or
an application access token (for Open
Graph Pages). For example, you can
post a new wall post on Arjun's wall
by issuing a POST request to
https://graph.facebook.com/arjun/feed:
curl -F 'access_token=...' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
so basically you retrieve the access token when the user authorizes your application, and store it for later use.
Quote found at http://developers.facebook.com/docs/api