Facebook API错误:页面不匹配(错误子代码:#1885029)

时间:2017-11-14 12:50:58

标签: php facebook facebook-php-sdk facebook-marketing-api

我现在正在使用facebook sdk for PHP(v2.10)。这是我创建AdSet的代码(我已经创建了广告系列)

//create new AdSet      
$adset = new AdSet(null, $_SESSION["facebook_account_id"]);

$adset->setData(array(
    AdSetFields::NAME => 'Peter//MyAdSet//PromotedObject//13112017-2',
    AdSetFields::PROMOTED_OBJECT => array(
        'page_id' => 126120924732396
    ),
    AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
    AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
    AdSetFields::BID_AMOUNT => 2,
    AdSetFields::DAILY_BUDGET => 1000,
    AdSetFields::CAMPAIGN_ID => $campaign_id,
    AdSetFields::TARGETING => (new Targeting())->setData(array(
        TargetingFields::GEO_LOCATIONS => array(
            'countries' => array(
                'VN',
            ),
        )
    )),
    AdSetFields::START_TIME =>
        (new \DateTime("+1 week"))->format(\DateTime::ISO8601),
          AdSetFields::END_TIME =>
        (new \DateTime("+2 week"))->format(\DateTime::ISO8601),
    ));

    $adset->validate()->create(array(
        AdSet::STATUS_PARAM_NAME => AdSet::STATUS_ACTIVE,
    ));

然后我创建一个广告

$creative = new AdCreative(null, $_SESSION["facebook_account_id"]);
        $creative->setData(array(
            AdCreativeFields::NAME => 'Peter//AdCreative//Sample//1',
            AdCreativeFields::TITLE => 'Welcome to our app',
            AdCreativeFields::BODY => "We've got fun 'n' games",
            AdCreativeFields::IMAGE_HASH => $image->hash,
            AdCreativeFields::OBJECT_URL => 'https://www.facebook.com/Test-Page-126120924732396',           
        ));

        $ad = new Ad(null, $_SESSION["facebook_account_id"]);
        $ad->setData(array(         
            AdFields::CREATIVE => $creative,
            AdFields::NAME => 'Peter//My First Ad//1',
            AdFields::ADSET_ID => $adset->id,
        ));

        $ad->create(array(
            Ad::STATUS_PARAM_NAME => Ad::STATUS_PAUSED,
        ));

之后我得到了一个错误

[error] => Array
     (
        [message] => Invalid parameter
        [type] => OAuthException
        [code] => 100
        [error_subcode] => 1885029
        [is_transient] => 
        [error_user_title] => Pages Don't Match
        [error_user_msg] => The Page selected for your ad doesn't match the Page associated with the object you're promoting, like a Page post or app.  Please make sure the Pages are the same.
        [fbtrace_id] => F0UwFAXCLQ2
      )

我使用沙盒帐户来测试facebook api,我已将测试页面连接到沙盒帐户。我的代码中缺少什么?

0 个答案:

没有答案