facebook / facebook-php-business-sdk

PHP SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
825 stars 514 forks source link

I can't create the creative through php SDKS #238

Closed zengyi584920 closed 8 years ago

zengyi584920 commented 8 years ago

This is my codes

    $link_data = new AdCreativeLinkData();
    $link_data->setData(array(
        AdCreativeLinkDataFields::MESSAGE => 'try it out',
        AdCreativeLinkDataFields::LINK => 'https://www.link.com',
        AdCreativeLinkDataFields::CAPTION => 'My caption',
        AdCreativeLinkDataFields::IMAGE_HASH => 'fd375de7eef1a...',
    ));

    $object_story_spec = new AdCreativeObjectStorySpec();
    $object_story_spec->setData(array(
        AdCreativeObjectStorySpecFields::PAGE_ID => "1759231...",
        AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
    ));

    $creative = new AdCreative(null, 'act_'.$adaccountid);

    $creative->setData(array(
        AdCreativeFields::NAME => 'Sample Creative2',     
        AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
    ));

    $creative->create();

The return message is "Invalid parameter" , who can help me? I realy can't find out this issue.

My english is so bad..Sorry.

But, i try it use this codes, it is success.

    $creative = new AdCreative(null, 'act_'.$adaccountid);

    $creative->setData(array(
        AdCreativeFields::NAME => 'Sample Creative',
        AdCreativeFields::TITLE => 'my title',
        AdCreativeFields::BODY => 'my body',
        AdCreativeFields::OBJECT_URL => 'https://www.link.com',
        AdCreativeFields::LINK_URL => 'https://www.link.com',
        AdCreativeFields::IMAGE_HASH => 'fd375de7eef1a...',
    ));

    $creative->create();

i don't know where is wrong. Help me! THS.

SantyagoSeaman commented 8 years ago

Hello! Make sure your AD account has all the necessary access rights to promoted page. I have had a couple of the same problems and all of them was solved only using careful transfer of all parameters and checking of all access rights. There is no framework or api issue. May be the error message can be a little bit more informative...

zengyi584920 commented 8 years ago

Thanks for you answer. This is my permissions

    if (!$_SESSION['facebook_access_token']) {
        $permissions = [
            'user_religion_politics',
            'user_tagged_places',
            'user_videos',
            'user_website',
            'user_work_history',
            'read_custom_friendlists',
            'read_insights',
            'read_audience_network_insights',
            'read_page_mailboxes',
            'manage_pages',
            'publish_pages',
            'publish_actions',
            'rsvp_event',
            'pages_show_list',
            'pages_manage_cta',
            'pages_manage_instant_articles',
            'ads_read',
            'ads_management',
            'pages_messaging',
            'pages_messaging_phone_number',
            'public_profile',
            'user_friends',
            'email',
            'user_about_me',
            'user_birthday',
            'user_education_history',
            'user_events',
            'user_games_activity',
            'user_hometown',
            'user_likes',
            'user_location',
            'user_managed_groups',
            'user_photos',
            'user_posts',
            'user_relationships',
            'user_relationship_details' 
        ];

        $loginUrl = $helper->getLoginUrl('http://192.168.1.223:8888/admin.php/welcome/GetToken', $permissions);
        echo '<a href="' . $loginUrl . '">Log in with Facebook</a>';

'ads_management', is my need? The version is 2.7

SantyagoSeaman commented 8 years ago

You should assign in the business manager your api user to promoted page with "page advertiser" rights. And check that you pass correct PAGE_ID. The careful checking is the only way to defeat this problem because even if you'll look at CURL response from the server you'll not find any additional useful information according to this problem.

zengyi584920 commented 8 years ago

Well, THS for your help. I will try it with other PAGE_ID.

zengyi584920 commented 8 years ago

This is a error message:

Array ( [error] => Array ( [message] => Invalid parameter [type] => OAuthException [code] => 100 [error_subcode] => 1885183 [is_transient] => [error_user_title] => Ads creative post was created by an app that is in development mode [error_user_msg] => Ads creative post was created by an app that is in development mode. It must be in public to create this ad. [fbtrace_id] => CUU1vYFcOT0 )

)

It's a development mode error.

duliomatos commented 8 years ago

Hey @zengyi584920, just go to https://developers.facebook.com/apps/<YOUR_APP_ID>, select App Review and click on the button to make the app public.

zengyi584920 commented 8 years ago

OK,thanks for your help