2013-05-15 67 views
2

我想將Facebook的評論社交插件 (https://developers.facebook.com/docs/reference/plugins/comments/評論網址)整合到我的android應用程序中。 我試圖使用webview(使用這個答案Android unable to implement facebook comment in a webview due to default browser),它的工作,但很難定製,例如:我想有一個更大的文本框供用戶鍵入評論。我的問題是:「有沒有什麼解決方案整合類似‘Facebook的評論社交插件’爲Android應用程序被Facebook SDK,Java代碼......對URLAndroid上的Facebook社交插件

感謝&問候

評論
+0

你找到解決方案相同嗎? –

回答

1

由於據我瞭解,你有一些網址頁面,你在其中嵌入了你的Facebook社交插件和評論,你想解析並顯示你想要的。如果我是正確的,那麼很遺憾,我沒有找到簡單的解決方案,通過觸發撥入你必須使用Graph API

首先我們需要看看文檔 - https://developers.facebook.com/docs/graph-api/reference/v2.3/object/comments

在這裏有呼叫

/* make the API call */ 
new Request(
    session, 
    "/{object-id}/comments", 
    null, 
    HttpMethod.GET, 
    new Request.Callback() { 
     public void onCompleted(Response response) { 
      /* handle the result */ 
     } 
    } 
).executeAsync(); 

的例子爲了得到{OBJECT_ID}你需要發送類似調用圖形API,但是對於檢索ID:

GET-> ?id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F 

你將收到看起來像

{ 
    "og_object": { 
    "id": "10150298925420108", 
    "description": "Directed by James Gunn. With Chris Pratt, Vin Diesel, Bradley Cooper, Zoe Saldana. A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe.", 
    "title": "Guardians of the Galaxy (2014)", 
    "type": "video.movie", 
    "updated_time": "2015-05-15T14:52:46+0000", 
    "url": "http://www.imdb.com/title/tt2015381/" 
    }, 
    "share": { 
    "comment_count": 4, 
    "share_count": 91073 
    }, 
    "id": "http://www.imdb.com/title/tt2015381/" 
} 

10150298925420108是ou [R OBJECT_ID

所以一個查詢看起來像GET -> 10150298925420108/comments 和響應

{ 
    "data": [ 
    { 
     "id": "10150298925420108_10152457293990108", 
     "can_remove": false, 
     "created_time": "2014-10-28T18:12:15+0000", 
     "from": { 
     "id": "1513986108857171", 
     "name": "ซอโซ่ สระอา ยอยัก" 
     }, 
     "like_count": 2, 
     "message": "สนุกมากค่ะ", 
     "user_likes": false 
    }, 
    { 
     "id": "10150298925420108_10152457392770108", 
     "can_remove": false, 
     "created_time": "2014-10-28T19:20:28+0000", 
     "from": { 
     "id": "302917246580502", 
     "name": "สมชาย โกทันธ์" 
     }, 
     "like_count": 0, 
     "message": "สองดาวครับ\n", 
     "user_likes": false 
    }, 
    { 
     "id": "10150298925420108_10152461977130108", 
     "can_remove": false, 
     "created_time": "2014-10-31T11:57:10+0000", 
     "from": { 
     "id": "472810482857795", 
     "name": "Surat Thaenphet" 
     }, 
     "like_count": 0, 
     "message": "แต่ละเรื่องที่ลง สนุกมาก แต่ดูไม่จบ ดูสักพัก ก็ eror ไม่รุ้เป็นเพราะอะไร", 
     "user_likes": false 
    } 
    ], 
    "paging": { 
    "cursors": { 
     "before": "Mw==", 
     "after": "MQ==" 
    } 
    } 
} 

要在Android應用做測試之前所有這些請求和響應 - 使用圖形API探險https://developers.facebook.com/tools/explorer/

+0

這是BY FAR嘗試在本機應用程序中執行註釋時發現的完全控制Graph API的最佳方法之一。雖然您應該更新一點點最新變化的答案。謝謝。 –