如何使用Facebook SDK 4.0共享或添加地点或办理登机手续?

问题描述 投票:0回答:2

我一直在探索Facebook文档,但仍然没有找到如何办理登机手续或分享地点。大多数答案已经弃用,我需要使用更新的Facebook SDK来实现。我在文档中遗漏了什么吗?或者我必须使用第三方应用程序???除了使用SDK共享的主要方式之外,我还知道如何在Facebook上共享媒体内容时使用ACTION_SEND,是否可以在那里插入一个位置参数?

android facebook-sdk-4.0
2个回答
1
投票

如果您使用Facebook分享按钮,它将是这样的

ShareContent sharecontent = new ShareLinkContent.Builder()
            .setPlaceId("141887372509674")
            .build();

    btnfacebookshare.setShareContent(sharecontent);

在ShareContents上放置一个placeID

您还可以使用SharePlaceId()的ShareContent子类,如SharePhotoContent,ShareVideoContent和ShareOpenGraphContent。

在文件(https://developers.facebook.com/docs/reference/android/current/class/ShareLinkContent/)上没有明确说明,但通过实验我想出了它


0
投票

需要使用GraphRequest请求placeId,可以使用以下方法完成:

    String facebookUrl = "https://www.facebook.com/mybusiness";
    final String PAGE_ID_FROM_URL = facebookUrl.substring(facebookUrl.lastIndexOf("/") + 1, facebookUrl.length());//now PAGE_ID_FROM_URL = mybusiness 
  //request for page id      
  new GraphRequest(AccessToken.getCurrentAccessToken(), "/"+ PAGE_ID_FROM_URL , null, HttpMethod.GET,
          new GraphRequest.Callback() {
             public void onCompleted(GraphResponse response) {
                    JSONObject obj = response.getJSONObject();
                        if (obj.has("id")) {
                            try {
                               String pageID = obj.getString("id");
                               ShareDialog share = new ShareDialog(MyActivity.this);
                               ShareContent shareContent = new ShareLinkContent.Builder().setPlaceId(pageID).setPageId(pageID).build();
                               share.show(shareContent, ShareDialog.Mode.AUTOMATIC);

                         } catch (JSONException e) {
                               e.printStackTrace();
                           }                   
    }
     }).executeAsync();
© www.soinside.com 2019 - 2024. All rights reserved.