Coder Social home page Coder Social logo

Comments (12)

phzhou avatar phzhou commented on April 27, 2024

Hi, did you include the ads_management permission when getting the the access token?
Please refer to the authentication guide here:
https://developers.facebook.com/docs/reference/ads-api/overview#access_token

from facebook-php-business-sdk.

paulbain avatar paulbain commented on April 27, 2024

Also, please make sure your application has been whitelisted for access to the Facebook Ads API

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

Thanks for responding.

@phzhou, no I had not done that. But it seems it didn't help.

I did the following:

  1. get the AUTHORIZATION_CODE from the URL after going here:
    https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&scope=ads_management&redirect_uri=https://www.my.com/

  2. get the $access_token from the response after going here:
    https://graph.facebook.com/oauth/access_token?
    client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
    client_secret=YOUR_APP_SECRET&code=AUTHORIZATION_CODE

My code looks like this:

        FacebookSession::setDefaultApplication($app_id, $app_secret);
        new Api(new FacebookSession($access_token));
        $set = new AdSet($ad_set_id);
        $set->{AdSetFields::NAME} = 'Test API Update';
        $set->update();

And I get back the exception mentioned above.

@paulbain How do I do that?

I read through this:
https://developers.facebook.com/docs/preferredmarketingdevelopers/ads-api-access

It indicated I needed to complete this application form:
https://www.facebook.com/help/contact/517221111658494

I did so, and was sent an approved email almost immediately.

The issue still persists.

from facebook-php-business-sdk.

paulbain avatar paulbain commented on April 27, 2024

It may be worth reaching out to the person from whom you received the email just to check it was whitelisted correctly.
Let me know your app id and I'll see if I can check also.

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

The email I thought was in reply to that contact was actually not. I have since received a reply to the whitelist request and they asked for the app id, and to ensure it was not in sandbox mode. It was in fact in sandbox mode.

Although it's not approved/working yet, I think this is the problem.

Thanks for the help.

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

I tried emailing [email protected] with a request to be whitelisted, however I still have not had a reply. I sent another email today and am hoping for a response.

Do you have any other suggestions regarding who I can contact to be whitelisted for ads api usage?

from facebook-php-business-sdk.

paulbain avatar paulbain commented on April 27, 2024

we opened up access for everyone now in development mode, take a look at:
https://developers.facebook.com/docs/reference/ads-api/access/v2.1

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

Hi @paulbain,

I added my Ad Account IDs to the app settings (App > Settings > Advanced > Ads API).

I also noticed that when I make calls on the Account ID, a different Account ID is also added to the app's settings.

Still getting the same error:
(#294) Managing advertisements requires the extended permission ads_management and an application that is whitelisted to access the Ads API

I have worked with Google Ads, Bing Ads and several others. I'm struggling to understand why FB Ad API has this barrier to entry.

Is there anyone at FB that I should contact for help, or would I be better of working with you in this thread?

Thanks for all your help so far.

from facebook-php-business-sdk.

paulbain avatar paulbain commented on April 27, 2024

in order to access advertising components of the Graph API, you need to request the ads_management permission from the user (which is probably you in this case). The key difference FB and other platforms is that we have a single unified platform which is permissioned.

Take a look at the getting started guide to see how to handle authentication:
https://developers.facebook.com/docs/reference/ads-api/overview#access_token

The best places to ask for help is either here for specific Ads API SDK issues, or StackOverflow for general technical questions and the marketing developer community on Facebook for more strategic/product questions:

http://stackoverflow.com/questions/tagged/facebook-ads-api
https://www.facebook.com/groups/pmdcommunity/

It would be great to hear your feedback onboarding with the SDK and how this can be improved also. That's probably best via messenger: fb.me/paulbain

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

Take a look at the getting started guide to see how to handle authentication:
https://developers.facebook.com/docs/reference/ads-api/overview#access_token

I did the following:

  1. get the AUTHORIZATION_CODE from the URL after going here:
    https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&scope=ads_management&redirect_uri=https://www.my.com/

  2. get the $access_token from the response after going here:
    https://graph.facebook.com/oauth/access_token?
    client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
    client_secret=YOUR_APP_SECRET&code=AUTHORIZATION_CODE

  3. I now have an $access_token, and I use it in the following code:

 FacebookSession::setDefaultApplication($app_id, $app_secret);
new Api(new FacebookSession($access_token));
$set = new AdSet($ad_set_id);
$set->{AdSetFields::NAME} = 'Test API Update';
$set->update();

This results in the error:

(#294) Managing advertisements requires the extended permission ads_management and an application that is whitelisted to access the Ads API

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

@paulbain,

As you suggested the issue was the Grey account. I added the account to the Business Manager as you suggested:
https://www.facebook.com/help/420039848100178

Seems to have got me past this error, however now I have a similar issue:
(#273) This Ads API call requires the user to be admin of the ad account. User XXX not admin on ad account YYY.

Do you know how I set my user to be the admin of the ad account?

Thanks for all your help.

from facebook-php-business-sdk.

cornernote avatar cornernote commented on April 27, 2024

Got it!

business.facebook.com > Settings > People > Assigned Ad Accounts

From here you can choose the role.

from facebook-php-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.