Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create AdAccount #89

Closed
alexkappa opened this issue May 18, 2015 · 10 comments
Closed

Create AdAccount #89

alexkappa opened this issue May 18, 2015 · 10 comments

Comments

@alexkappa
Copy link

Hello,

I was wondering why ad accounts cannot be created using the SDK.

From the API documentation it seems allowed to create an ad account but in the SDK the AdAccount class uses the CannotCreate trait.

Thanks,
Alex

@pruno
Copy link
Contributor

pruno commented May 18, 2015

Hi @alexkappa,

Through the API, only accounts owned by a business (not a user) can be created. Despite we are working on it, the SDK doesn't yet support the business manager API objects.

If you need to access that endpoint i suggest you temporary create the account through a direct API call (you i'll be able to read and update the account through the AdAccount class).

$response = Api::instance()->call(
  '/<BUSINESS_ID>/adaccounts',
  RequestInterface::METHOD_POST,
 array(
   AdAccountFields::NAME => 'My Business Account',
   // All other required params 
  )
);

$account_id = $response->getContent()[AdAccountFields::ID];

$account = new AdAccount($account_id);

Note: i haven't tested this code :)

@alexkappa
Copy link
Author

Thanks @pruno, we'll work around it for the time being and will be looking forward to having support for business manager objects in the SDK.

Cheers!

@allentsai
Copy link

Quick note for anyone who stumbles upon this issue. The example uses '/<BUSINESS_ID>/adaccounts', but the path should really be '/<BUSINESS_ID>/adaccount' (no 's').

If you search the facebook docs (https://developers.facebook.com/docs/marketing-api/reference/ad-account) you will find two sets of documentation:
/{business_id}/adaccounts
and
/{business_id}/adaccount
adaccounts probably adds an existing ad account to a business manager, since one of the required parameters is adaccount_id which a non-existing ad account would not have. Unless I am missing something obvious.

@newerton
Copy link
Contributor

newerton commented May 20, 2016

It is possible to create the user uses AdAccount?

My code:

$fieldsRequired = [
    'name' => 'My Ad Account',
    'currency' => 'USD',
    'timezone_id' => 7,
];
$accounts = $fb->post('/me/adaccounts', $fieldsRequired);

(#275) Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.

Where am I going wrong? It is obligatory to have the BUSINESS_ID instead of /me?

PHP 7.0.3 (cli) (built: Feb  2 2016 14:38:29) ( ZTS )
APP NAME: YAN ADS
APP ID: 839376919517850
Mode: Development
Access: User Test
[
   'id' => 102771566809618,
   'name' => 'Betty Alabcjcbdbehg Zamoreman',
   'email' => 'twouxdy_zamoreman_1463762908@tfbnw.net'
]

cURL Log

curl \
  -F 'name=Betty Alabcjcbdbehg Zamoreman' \
  -F 'currency=BRL' \
  -F 'timezone_id=25' \
  -F 'access_token=EAAL...' \
  -F 'appsecret_proof=99212...' \
  https://graph.facebook.com/v2.6/me/adaccounts

Sorry my English!

@newerton
Copy link
Contributor

newerton commented Jun 2, 2016

@alexkappa Solve this problem of creating Account?

@ianberdin
Copy link

@newerton Did you solve this? I can't create with my business id too...

@newerton
Copy link
Contributor

@happierall Without solution. In my case, I direct the client to Facebook Ads, automatically creates the account for the user.

My project is stopped. I was using version 2.6. Today it is in version 2.9, and did not solve this problem.

In the documentation, it would have to work.
Https://developers.facebook.com/docs/marketing-api/reference/ad-account#Creating

@ianberdin
Copy link

ianberdin commented Jun 28, 2017 via email

@newerton
Copy link
Contributor

The code below should be implemented. Using the user session.

$fieldsRequired = [
    'name' => 'My Ad Account',
    'currency' => 'USD',
    'timezone_id' => 7,
];
$accounts = $fb->post('/me/adaccounts', $fieldsRequired);

@GuangStack
Copy link

(#275) Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.
Why ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants