0

我正在通过 Facebook Graph API 检索我的墙贴me/home,我得到了这样的数据:

{
"data": [
{
  "id": "434028623322619_685556731503139", 
  "from": {
    "category": "Games/toys", 
    "name": "Gameloft", 
    "id": "434028623322619"
  }, 
  "to": {
    "data": [
      {
        "category": "App page", 
        "name": "World at Arms", 
        "id": "354464541311978"
      }
    ]
  }, 
  "full_picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQBMneZMJOUbYmab&url=https%3A%2F%2Ffbcdn-photos-h-a.akamaihd.net%2Fhphotos-ak-prn2%2Ft1.0-0%2F10325354_685556454836500_2869075300782966829_s.jpg", 
  "link": "https://www.facebook.com/GameloftFR/photos/a.434045733320908.96670.434028623322619/685556454836500/?type=1&relevant_count=1", 
  "actions": [
    {
      "name": "Comment", 
      "link": "https://www.facebook.com/434028623322619/posts/685556731503139"
    }, 
    {
      "name": "Like", 
      "link": "https://www.facebook.com/434028623322619/posts/685556731503139"
    }
  ], 
  "type": "photo", 
  "status_type": "added_photos", 
  "created_time": 1400751098, 
  "updated_time": 1400751098, 
  "message": "Qui a déjà testé les nouveaux hélicos de l'update de World at Arms  \n\nPostez nous vos plus belles images de combats en commentaire ! :-)\n\nTéléchargez le jeu sur #iOS et #Android : http://gmlft.co/V-wdI\n\nRetrouvez le #GameloftDirect dédié à cette nouvelle update ici : http://gmlft.co/6V8ny", 
  "object_id": "685556454836500"
}, 
{
  "id": "297172963760_10152858184403761", 
  "from": {
    "category": "Non-profit organization", 
    "category_list": [
      {
        "id": "10101384669488041", 
        "name": "Non-Profit Organization"
      }
    ], 
    "name": "Fédération Française de Gymnastique", 
    "id": "297172963760"
  }, 
  "name": "31èmes Championnats d'Europe de Gymnastique Artistique Masculine", 
  "story": "Fédération Française de Gymnastique added 10 new photos to the album 31èmes Championnats d'Europe de Gymnastique Artistique Masculine.", 
  "full_picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQBuTwqYKGVuA-Yp&url=https%3A%2F%2Ffbcdn-photos-g-a.akamaihd.net%2Fhphotos-ak-frc3%2Ft1.0-0%2F10374508_10152858178588761_2381196158150497207_s.jpg", 
  "link": "https://www.facebook.com/photo.php?fbid=10152858178588761&set=a.10152856981978761.1073741840.297172963760&type=1&relevant_count=10", 
  "caption": "Retrouvez des photos des Championnats d'Europe mi-mai à Sofia (Bulgarie).", 
  "actions": [
    {
      "name": "Comment", 
      "link": "https://www.facebook.com/297172963760/posts/10152858184403761"
    }, 
    {
      "name": "Like", 
      "link": "https://www.facebook.com/297172963760/posts/10152858184403761"
    }
  ], 
  "type": "photo", 
  "status_type": "added_photos", 
  "created_time": 1400749843, 
  "updated_time": 1400749843, 
  "object_id": "10152858178588761"
}
] 
}

现在我想使用feedDialog分享其中一篇文章:

private void publishFeedDialog() {
Bundle params = new Bundle();
params.putString("name", "Facebook SDK for Android");
params.putString("caption", "Build great social apps and get more installs.");
params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

WebDialog feedDialog = (
    new WebDialog.FeedDialogBuilder(getActivity(),
        Session.getActiveSession(),
        params))
    .setOnCompleteListener(new OnCompleteListener() {

        @Override
        public void onComplete(Bundle values,
            FacebookException error) {
            if (error == null) {
                // When the story is posted, echo the success
                // and the post Id.
                final String postId = values.getString("post_id");
                if (postId != null) {
                    Toast.makeText(getActivity(),
                        "Posted story, id: "+postId,
                        Toast.LENGTH_SHORT).show();
                } else {
                    // User clicked the Cancel button
                    Toast.makeText(getActivity().getApplicationContext(), 
                        "Publish cancelled", 
                        Toast.LENGTH_SHORT).show();
                }
            } else if (error instanceof FacebookOperationCanceledException) {
                // User clicked the "x" button
                Toast.makeText(getActivity().getApplicationContext(), 
                    "Publish cancelled", 
                    Toast.LENGTH_SHORT).show();
            } else {
                // Generic, ex: network error
                Toast.makeText(getActivity().getApplicationContext(), 
                    "Error posting story", 
                    Toast.LENGTH_SHORT).show();
            }
        }

    })
    .build();
feedDialog.show();
}

有没有办法直接使用帖子 ID(例如:434028623322619_685556731503139)或其他任何方式分享帖子并让 feedDialog 获取所需的信息?

我的意思和网络共享者一样,你粘贴一个链接,Facebook 会尝试抓取页面信息(通过 og 或抓取)

4

1 回答 1

0

您可以使用 facebook graph api 和 php sdk 来完成。我为此创建了一个类似的应用程序。您可以从此链接facebook 多张海报获得该应用程序的演示

于 2015-02-27T10:26:00.147 回答