I'm attempting to set up a way to retrieve Facebook Lead Ads as per instructions given here: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/
However on subscribing a page to the App, I'm getting the following error on printing the response:
code: 200
error_subcode: 1373034
error_user_msg: "You do not have the necessary permission for the
specified Page to perform the requested action."
error_user_title: "Insufficient Permission"
fbtrace_id: "CLbnoml6VX1"
is_transient: false
message: "Permissions error"
type: "OAuthException"
Here is the segment of code used to subscribe the app:
function subscribeApp(page_id, page_access_token) {
console.log('Page Access Token:'+page_access_token);
console.log('Subscribed Page to FB Leads Live Update. Page ID: ' + page_id);
FB.api('/' + page_id + '/subscribed_apps',
'post',
{access_token: page_access_token, subscribed_fields: 'leadgen'},
function(response)
{console.log('Successfully subscribed page', response);
});
}
I suspect that the page being subscribed is in question here (as the error states), and must be set accordingly to be subscribed to my app. I should state that the page is already subscribed to another app, and I'm using this page for testing purposes on my second FB App for another web application. Any insight would be appreciated!
Same situation.
Your assumption is correct. You can't have 2 apps attached to capture leads.
Once the other app is disconnected and enough time has passed (No explanation of how long), permissions will be set correctly
Related
I've created a Facebook app, linked it with a business, submitted and passed review, the business is verified, contracts signed, the app has leads_retrieval permission, the app status is now live.
I can test it under the webhooks link in the side menu, my end point receives the test data from Facebook. The data shown below is received by my server.
When I test using the lead ads testing tool I instantly get a 102, server error, and nothing is received by my server. See below for the message.
I've spent so long getting to this stage and every step has been painful!
Can anyone suggest why using the lead ads testing tool results in an error and what I can do to resolve the issue.
Cheers
I've been struggling with this too.. Apparently you can't use it on development apps anymore. Found the answer here: https://stackoverflow.com/a/57397525/8439792
I think I found your problem! It is when you subscribe to your apps. Here is the link that shows the subscribed_fields and scope should be:
https://stackoverflow.com/a/54713182/7313872
I was going straight from the demo and the subscribed_fields is set to 'feeds' and the scope was only manage_pages. You need to change it like in the example in the above link. I will also provide the snippets I changed below:
subscribed_fields - in subscribe apps function
FB.api(
'/' + page_id + '/subscribed_apps',
'post',
{access_token: page_access_token, subscribed_fields: 'leadgen'},
function(response) {
console.log('Successfully subscribed page', response);
}
);
scope - end of facebook login function
{scope: ['manage_pages', 'leads_retrieval']});
Hope this helps!
Facebook had the problem in their startup documentation for the webhooks. I have notified them in a bug, and does look like they have fixed the documentation to now subscribe to "leadgen" and not "feeds".
https://developers.facebook.com/support/bugs/681262475926363/
https://developers.facebook.com/docs/marketing-api/guides/lead-ads/quickstart/webhooks-integration/
I have a Facebook App (a game) that is perfectly working if I access the URLs directly (https://apps.facebook.com/[appnamespace]/ or https://mydomain.com/, the last one being the canvas URL).
But every time I submit the app for review I get the following feedback: "Please address the following feedback from our review team. Once you have made the changes listed below you may resubmit for review." and "Your app's Canvas page doesn't load".
Problem is I don't really know what to change because for me and for friends with whom I shared the link it's working as expected.
I have only one error in the console in Chrome which is:
"Unsafe JavaScript attempt to access frame with URL https://apps.facebook.com/[appnamespace]/ from frame with URL https://mydomain.com/. The frame being accessed set 'document.domain' to 'facebook.com', but the frame requesting access did not. Both must set 'document.domain' to the same value to allow access.
I don't have document.domain specified in my page though I tried some values before to get rid of this error message without success. And every time I set a value for document.domain I get another error in the console: "Uncaught Error: SecurityError: DOM Exception 18".
I didn't find anything on this that is working.
So any help/hint would be appreciated. I also tried to ask for more detailed feedback in the review description message but I still get the same message with no clue on how to solve the problem.
Thanks.
So I finally solved the issue.
The problem was that I didn't test the app when the user is not connected to Facebook. For me the app was not supposed to be used outside Facebook game center (though it's possible) and Facebook probably test this case during app review. Hence none of the following events gets fired:
auth.statusChange
auth.authResponseChange
auth.login
To tackle this problem I make a call to getLoginStatus, something like this:
FB.getLoginStatus(function (response) {
console.log('[Facebook] getLoginStatus: ' + response.status);
if (response.status !== 'connected' &&
response.status !== 'not_authorized')
{
console.log('[Facebook] not connected');
$('#loginscreen').show();
$('#btn-fb-login').click(function (event) {
event.preventDefault();
FB.login(function (response) {
$('#loginscreen').hide();
start(response);
}, { scope: 'email,publish_actions'});
});
}
});
I use
FB.api('/me/apprequests/?access_token=' + access_token + '&date_format=' + escape('Y/m/d H:i:s eO'), function(response) {
if(response.error)
{
to get user's app requests.
but some times,some users cannot get the app requests list.
only get
{"error":{"type":"http","message":"unknown error"}}
some users may get this error all the time.
I trace this error to my GA quality,Statistical results show some users get this error As many as tens of thousands of times.
the access_token is the current user's.
why some user get unknown error with type http?
I do not get this.
thank you.
thanks for your answer.
I think this error is not caused due to the permission.because I log the access_token when one error occurs.and use facebook debug tool check it.It shows
Issued:
1362702044 (about an hour ago)
Expires:
1367886044 (in about 2 months)
Valid: True
Origin: Web
Scopes: email publish_actions user_games_activity
.So ,I do not known why those problem occur.
I have the same problem and it is resolved now.
The error message : {"error":{"type":"http","message":"unknown error"}}
means FB API's response is broken because of some other action in the page.
In my scenario, I put a html tag :button in a form, and this button is to invoke FB.api. However, when a user clicks the button, the form will be submitted automatically and does not wait the response of FB.api.
The code is as below:
<form>
<button onclick="test();">Test</button>
</form>
function test(){
FB.api('/me', function(response) {
alert(response.name);
});
}
I add "return false;" in button's onclick method after it calls test() to avoid the form automatically submitting.
I suggest you to check the javascript in the page to confirm there is no action occurs during interactive function with FB.
I have setup the facebook javascript sdk to initialize a friend invite dialog to send requests to friends. Clicking on the invite in Facebook, brings the user back to the site.
The query string has any and all request_ids that have not been handled (deleted).
I am following the documenation listed at the FB developers site here which states:
JavaScript SDK:
FB.api(requestId, 'delete', function(response) {
When they are returned to my site, the querystring has a request_ids parameter:
example: www.mysite.com/somepage?request_ids=0493834050
my Javascript code looks like this:
FB.api(requestIds[i], 'delete', function (response) {
console.log(response);
});
But the error I get is:
ERROR
code: 104
message: "An access token is required to request this resource."
type: "OAuthException"
All I want to do is delete the request ID. before I was even running the above code, the querystring was building up with every submitted request. It does appear they have been removed, because the querystring is reduced down to a single request id. But I am still uncertain it has been handled properly.
NOTE I am not using the Graph version - as I have not setup Graph on the app settings in Facebook.
I have the Facebook C# sdk - if someone has an easy way to do this here. I have tried the following with the same results.
var fbClient = new FacebookClient(accessToken)
fbClient.Delete(requestId);
I don’t see what’s possibly unclear about the error message – you need a valid access token to be able to delete requests, but by the looks of it you don’t have one.
So you’ll either have to have the user connect to your app in order to get an active access token for him; or you have to do it using your own app access token (but that’d have to be done server-side then, because you don’t want to transfer your app access token to the client side).
I'm trying to post a reply to an inbox message by sending a POST request to /message_id/comments. Is this the correct way to send a reply to an inbox message ?
I'm getting the following error:
"error": {
"type": "OAuthException",
"message": "(#3) App must be on whitelist"
}
The token has every possible permission.
Do I have to ask that my app is added on a whitelist ? how to do so ?
I'm doing this in javascript+jQuery:
var params = {
access_token: token
, method: 'post'
, message: 'hi'
};
$.getJSON('https://graph.facebook.com/$message_id/comments?callback=?', params, function(json) {
});
Facebook apps by default aren't allowed to send messages on behalf of users. There is no permission you are missing. This is an extra level to prevent spam (beyond prompting the user who). You will have to contact Facebook to get your application whitelisted. I would try their developer group.
opened a support ticket right here:
http://developers.facebook.com/bugs/183144141763793?browse=search_4e8b140cbf26e6040457329
Tried all I can think of and googled for, still getting this issue
Like others have pointed out, there isn't a way to do this programmatically unless you are on Facebook's whitelist. However, I did find a way around this for my app. What I do is use Oauth to display messages from a user's FB inbox like normal. When the user clicks 'Reply' on a message, I just send them to the reply page on Facebook Mobile, like this:
$('.reply').click(function() {
var popup_window = window.open('http://touch.facebook.com/messages/compose?ids='+message_id, '_blank');
popup_window.focus();
});
Where message id is the Facebook id for the message they are replying to. In my case, I use PHP to echo the message id into a javascript variable or data-attribute when the page loads. Since the Facebook mobile page opens in a new tab, they don't even really leave my app. Since Facebook mobile has a very streamlined interface it isn't too distracting. It's not perfect, but it works and it's easier than trying to get whitelisted.