Graph API 版本

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

作為 3.3 版變更的一部分,我們已停用 read_page_mailboxes 權限。請使用 pages_messaging 權限來存取此端點。read_page_mailboxes 權限將於 2020 年 6 月 30 日之後失效

在訊息中分享商品。此端點僅適用於專頁。

讀取

Graph 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 上的商品範本只適用於 Graph 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"
                            },
                            {..}],
                        }
                    }
                }
            }
    }]
}    

發佈

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

刪除

您無法使用此邊緣刪除內容。

更新

您無法使用此邊緣作出更新。