圖形 API 版本

圖形 API 參考資料 /{message-id}/shares

read_page_mailboxes 權限是第 3.3 版變更的一部分,已遭停用。使用 pages_messaging 權限可存取此端點。read_page_mailboxes 權限將於 2020 年 6 月 30 日後停止運作

訊息中的分享項目。此端點僅適用於粉絲專頁。

讀取

圖形 API 測試工具
GET /v19.0/{message-id}/shares HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{message-id}/shares',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{message-id}/shares",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{message-id}/shares",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{message-id}/shares"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

這個關係連線需要具備下列權限的粉絲專頁存取權杖:

  • pages_messaging

開發模式中的應用程式僅限於傳送訊息給在應用程式中擁有角色的人。

欄位

名稱 說明 類型

description

分享項目的說明。

string

link

分享項目的網址。

string

id

分享項目的編號。

string

name

分享項目的標題。

string

template

分享項目的物件。

Object

template.payload.product.elements

只有當商家可以查看產品時,此功能才可用。若是不屬於商家的產品,系統將傳回 shares.data.name 作為 Attachment Unavailable

屬性 類型 說明

id

字串

Facebook 商品目錄的產品編號

retailer_id

字串

與產品相關聯的外部編號。(例如:SKU/內容編號)

image_url

字串

產品圖像網址

title

字串

產品標題

price

字串

產品價格

產品範本的範例

轉換 API 的產品範本僅適用於圖形 API 8.0 以上版本

應用程式需要具有核准的catalog_management 權限,才能在轉換 API 中接收產品詳細資料。

"shares": {
    "data": [{
       "template": {
            "payload":{
                "product": {
                    "elements":{ // multiple elements in Hscroll
                        "data": [
                            {
                                "id" : "<Product_id>",
                                "retailer_id": "<EXTERNAL_ID>", 
                                "image_url" : "https://fb.cdn.com/sdsd",
                                "name" : "Some product title",
                                "price" : "$10"
                            },
                            {..}],
                        }
                    }
                }
            }
    }]
}    

發佈

您無法使用這個關係連線發佈內容。

刪除

您無法使用這個關係連線刪除。

更新

您無法使用這個關係連線更新。