last day (14 days later) » 

11:10 AM
0
Q: Create Facebook Campaign and Ad Sets using the Facebook API without the permission error

rawatdeepeshI am using the Graph API provided by Facebook to create an advert. I have done the following: 1- FB.Login() from my webpage with the respective permissions ,i.e, { scope: 'publish_pages, manage_pages, publish_actions,ads_management'} 2- Used me/accounts node to get to the appropriate Facebook p...

 
“The response returned is [object Object]” - that’s because you are forcing it to be cast into a string, by concatenating it with other stuff. Don’t do that, output the object directly, so that you can expect it on console.
Have you actually done what the error message says still needs doing?
 
Thanks for the suggestion. I checked in console with the string concatenation. The error shown is error: code:100 type:OAuthException
 
At what specific point in the script? Most likely a permission or token issue. Permissions are not asked for via FB.api, I don’t know what makes people regularly get that idea.
 
I already have posted as a Page with the permissions,i.e., by asking for the access_token of the related page which required { scope: 'publish_pages, manage_pages, publish_actions,ads_management'} where publish_pages was needed for publishing/posting as a page. However this time I need to create an Advert which also needs ads_management, which I have already provided in that scope. The Error appears right after I call the POST for the advert FB.api('/my_adaccountid/campaigns', 'post', { name: advertname, objective:"LINK_CLICKS"}, function(info){console.log(info); //error thrown
 
“which also needs ads_management, which I have already provided in that scope - in what scope? Again: Passing a scope to FB.api makes no sense at all, that is not how you ask for permissions.
And your screenshot from Graph API Explorer suggests that you are using that with the Graph API Explorer app id - which you for sure will not have added your ad account to. You might want to start by selecting your app from the dropdown in the upper right corner ...
 
11:10 AM
{ scope: 'publish_pages, manage_pages,publish_actions,ads_management'} <= this scope. In my previous scenario I could not post as a Page until I added the Publish permission for page in the scope. It would not post as a page and would post on my behalf. I have additionally added the adaccount in my app's advanced settings. Kindly let me know if this is not the right way. Thanks for the insight
 
“this scope” - where???
 
Hello , By scope I mean the set of permissions I add along with the API call
FB.api('/act_25914426/campaigns', 'post', {
name: advertname,
objective:"LINK_CLICKS",
access_token : pageAccessToken
}, function(info){
console.log("before 135");
console.log(info);

},{ scope: 'publish_pages, manage_pages, publish_actions,ads_management'} );
 
Ah, so you did not ask for them at all then.
 
I have asked most of the permissions in graph explorer while asking for a token. Additionally I have added these permission in the part where they ask to review the app
DO you mean to say that the permissions are meant to be asked somewhere else ?
 
Yes ... as I have said twice already now, asking permissions does not happen via FB.api - that method makes API calls, nothing else. developers.facebook.com/docs/facebook-login/permissions/…
 
11:22 AM
Let me just add, I added read_insights to that scope and then it did ask for permission on page refresh for the first time
let me quickly show u the screenshot if thats ok
 
11:40 AM
Even the link you shared says so :

Requesting & Revoking Permissions

Each type of login flow has its own method of requesting permissions, depending on your platform and how you choose to integrate Facebook Login:

Web

The Facebook JavaScript SDK uses a scope option with the FB.login function call.
 
12:40 PM
Yes, even that says that you need to use FB.login (L-O-G-I-N) to ask for permissions ... so why you insist on doing it usin FB.api (A-P-I), or even thought that would make sense in the first place, dunno.
 
1:30 PM
Yes that is what I have been doing, I ask for permissions in scope that FB.LOGIN

FB.login(function(){
// used to get user accessToken
var pageId = '1928652150728161'; // facebook page id from page info
var authResp = FB.getAuthResponse();
var postdesc= "https://hindwarelivestorage.blob.core.windows.net/image/03082017956550.png";
var jla="So this is it www.facebook.com/pageid";
//PostwithAuth(pageId,authResp,postdesc,jla);
}, { scope: 'publish_pages, manage_pages, publish_actions,ads_management' });
I just added the same permissions in scope with FB.API since it wasn't working out
 

last day (14 days later) »