How can i get canonical url from facebook graph ap

2019-02-21 02:35发布

Am trying to implement deep link on Facebook sharing in my android applcation. That deep link is only for mobile and not for webpage. So according to the facebook documentation Link1 Link2 am going through Link2. The following should be called to get id of canonical url. This canonical url will be set as a link on Facebook sharing.

To get canonical id

curl https://graph.facebook.com/app/app_link_hosts \
-F access_token="APP_ACCESS_TOKEN" \
-F name="Android App Link Object Example" \
-F android=' [
    {
      "url" : "sharesample://story/1234",
      "package" : "com.facebook.samples.sharesample",
      "app_name" : "ShareSample",
    },
  ]' \
-F web=' {
    "should_fallback" : false,
  }'

To get canonical url from canonical id

curl -G https://graph.facebook.com/YOUR_APP_LINK_HOST_ID \
-d access_token="APP_ACCESS_TOKEN" \
-d fields=canonical_url \
-d pretty=true

I don't know how to call this and i don't know the terms app_link_hosts, Android App Link Object Example, YOUR_APP_LINK_HOST_ID here actually means. Can anyone explain how to call this with example. Thank you.

1条回答
Summer. ? 凉城
2楼-- · 2019-02-21 03:30
  1. app_link_hosts is part of the actual graph path for the request, so don't change it, and just use it as is (/app/app_link_hosts is the full path).

  2. "Android App Link Object Example" is the name of the url you're creating. It's for your benefit only, and is not really used for anything, so you can put anything you'd like there (I would keep it a human readable string).

  3. "YOUR_APP_LINK_HOST_ID" is the result from the first curl command. The first curl command will return you a string ID, and you use that in the second command to get the canonical url (that you can use to share).

查看更多
登录 后发表回答