簡體   English   中英

從 facebook API 獲取所有潛在客戶廣告

[英]Get all lead ads form facebook API

我正在嘗試使用 Facebook ZDB974238714CA8DE634A7CE1DF083 版本在我的 PHP 腳本中獲取所有潛在客戶生成 forms

我提出這樣的要求:

https://graph.facebook.com/v9.0/<PAGE_ID>/leadgen_forms?<access_token>

但它的返回錯誤,說

{
   "error": {
      "message": "(#12) leadgen_forms field is deprecated for versions v5.0 and higher",
      "type": "OAuthException",
      "code": 12,
      "fbtrace_id": "ARMp3WCko2raN5521458h"
   }
}

如果我在上述請求中更改版本,它會說:

您正在調用已棄用的廣告 API 版本。 請更新到最新版本:v9.0。

更新:

這是 SDK function,我用來獲取潛在客戶生成 Forms:

public function getLeadGenForms(array $fields = array('first_name', 'last_name'), array $params = array(), $pending = false) {
    $this->assureId();

    $param_types = array(
      'query' => 'string',
    );
    $enums = array(
    );

    $request = new ApiRequest(
      $this->api,
      $this->data['id'],
      RequestInterface::METHOD_GET,
      '/leadgen_forms',
      new LeadgenForm(),
      'EDGE',
      LeadgenForm::getFieldsEnum()->getValues(),
      new TypeChecker($param_types, $enums)
    );
    $request->addParams($params);
    $request->addFields($fields);
    return $pending ? $request : $request->execute();
  }

這是正確的 GET 請求 URL:

https://graph.facebook.com/v9.0/<PAGE_ID>/leadgen_forms?access_token=<page_access_token>

以及使用 FB PHP SDK 的示例:

try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/<PAGE_ID>/leadgen_forms',
    '{access-token}'
  );
} catch(FacebookExceptionsFacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(FacebookExceptionsFacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();

來源:從圖 API Explorer生成。

工作無錯誤響應的屏幕截圖: 在此處輸入圖像描述

要求:

  • 使用頁面<PAGE_ID>頁面訪問令牌(不是您自己的用戶令牌或任何其他頁面)。
  • pages_show_listpages_read_engagementpages_manage_ads權限授予您連接到的 FB 應用程序(以獲取頁面訪問令牌)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM