You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Facebook Graph API创建Adset遇错误码2490027如何解决?

错误码2490027分析与修复方案

错误原因

错误子码2490027对应的是创建Adset时缺少必填参数。Meta广告组创建API要求必须提供以下核心参数,你的代码中完全缺失:

  • 预算参数:daily_budget(日预算)或lifetime_budget(终身预算)二选一
  • 优化目标:optimization_goal(需与billing_event匹配)
  • 出价策略:bid_strategy

另外,billing_event设为IMPRESSIONS时,必须搭配对应的优化目标,否则也会触发参数无效错误。

代码修正步骤

  1. 补充必填参数:在adset_data中添加预算、优化目标和出价策略
  2. 注意预算单位:Meta API使用最小货币单位,比如印度卢比(INR)需传入派萨数值(100卢比=10000)
  3. 匹配优化目标与计费事件:当billing_event为IMPRESSIONS时,optimization_goal可设为REACH或IMPRESSIONS

修正后的完整代码片段:

$url="https://graph.facebook.com/v18.0/act_".$ad_account_id."/adsets";

$this->create_fb_user_access($user_id);

$client = new \GuzzleHttp\Client();

// 补充必填参数后的Adset数据
$adset_data = [
    'name' => 'Your Ad Set Name',
    'campaign_id' => $campaign_id,
    'targeting' => [
        'geo_locations' => [
            'countries' => ['IN'],
        ],
    ],
    'billing_event' => 'IMPRESSIONS',
    // 添加日预算(单位:派萨,10000=100卢比)
    'daily_budget' => '10000',
    // 匹配计费事件的优化目标
    'optimization_goal' => 'IMPRESSIONS',
    // 设置出价策略
    'bid_strategy' => 'LOWEST_COST_WITHOUT_CAP',
];


try {
    $response = $client->post($url, [
        'headers' => [
            'Content-Type' => 'application/json',
        ],
        'query' => [
            'access_token' => $this->userAccessToken,
        ],
        'json' => $adset_data,
    ]);

    $data = json_decode($response->getBody()->getContents(), true);

    return $data['id'];
} catch (\Exception $e) {
    // 建议捕获Guzzle的RequestException以获取更详细的错误响应
    if ($e instanceof \GuzzleHttp\Exception\RequestException) {
        $errorResponse = json_decode($e->getResponse()->getBody()->getContents(), true);
        dd($errorResponse);
    }
    dd($e->getMessage());
}

额外检查项

  • 确认userAccessToken拥有ads_management权限
  • 验证campaign_id属于指定的广告账户act_xxx
  • 确保广告账户的状态正常,没有被限制

内容的提问来源于stack exchange,提问作者codewiz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 09:33:10