duanbei2914 2015-08-25 23:50
浏览 37
已采纳

Facebook图形PHP API批量请求

I am trying to get to get clicks and spend data for ad campaigns.

I am currently getting all ad campaign ID's with a curl request which returns about 260 ID's.

I want to make a batch request and get the clicks, spend, start and end dates for each ID.

I have found the PHP SDK FacebookRequest() function very confusing so have been trying to make cURL requests.

Would really appreciate some help because I am just stumped at the moment. Is it best to use to FacebookRequest() function or can I continue using the cURL requests?

Not sure if I am on the right track but essentially what I have at the moment is all the campaign ID's which I group with a method, relative_url and body and then pass to a requestHandler function. The code is as follows:

    $ad_account_ids = <ad_account_id>;

    $ad_campaign_ids = FbAdCampaign::all()->lists('ad_campaign_id')->toArray();

    foreach ($ad_campaign_ids as $key => $value) {
        $ad_campaign_ids[$key] = array(
            "method" => "GET",
            "relative_url" => "v2.4/act_".$ad_account_ids."/adgroups",
            "body" => "campaign_id=".$value."&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"US\"]}&name=test1"
            );
        $fields[] = array(
            'access_token' => $access_token,
            'batch' => $ad_campaign_ids[$key]
            );

    // $url = 'https://graph.facebook.com/v2.4/act_'.$ad_campaign_ids.'/adcampaign_groups?access_token='.$access_token;
    $url = 'https://graph.facebook.com/';

    $data = RequestHandler::curlRequest($url);
  • 写回答

1条回答 默认 最新

  • dto5637 2015-08-26 03:50
    关注

    Ok got it.

    Had to prepend the /GET data to the end of the URL to pass to the request handler.

    as follows:

    $url = 'https://graph.facebook.com/v2.3/act_'.$ad_account_ids.'/adcampaign_groups?access_token='.$access_token;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥200 csgo2的viewmatrix值是否还有别的获取方式
  • ¥15 Stable Diffusion,用Ebsynth utility在视频选帧图重绘,第一步报错,蒙版和帧图没法生成,怎么处理啊
  • ¥15 请把下列每一行代码完整地读懂并注释出来
  • ¥15 pycharm运行main文件,显示没有conda环境
  • ¥15 易优eyoucms关于二级栏目调用的问题
  • ¥15 寻找公式识别开发,自动识别整页文档、图像公式的软件
  • ¥15 为什么eclipse不能再下载了?
  • ¥15 编辑cmake lists 明明写了project项目名,但是还是报错怎么回事
  • ¥15 关于#计算机视觉#的问题:求一份高质量桥梁多病害数据集
  • ¥15 特定网页无法访问,已排除网页问题