How can i get canonical url from facebook graph api in android?

倖福魔咒の 提交于 2019-12-19 11:55:20

问题


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:


  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).



来源:https://stackoverflow.com/questions/28830770/how-can-i-get-canonical-url-from-facebook-graph-api-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!