2015-05-22 60 views
1

我想檢查用戶是否在谷歌加分享我的內容,我試過onendinteraction回調,但用戶可以點擊關閉按鈕,而不是共享按鈕,所以我是否需要檢測用戶最初共享的內容?如何從Google+共享API獲取回覆關於用戶是否共享鏈接

+0

[google + share和onendinteraction - no confirm]的可能重複(http://stackoverflow.com/questions/18375727/google-share-and-onendinteraction-no-confirm) – abraham

回答

0

剛注意到這個鏈接的問題。我回答它another post但這裏要再次重申 -

根據Google Developer頁爲他們的網絡平臺,它似乎可以用類似於JavaScript代碼挖掘到當前用戶的活動清單 -

var request = gapi.client.plus.activities.list({ 
    'userId' : 'me', 
    'collection' : 'public' 
}); 

request.execute(function(resp) { 
    var numItems = resp.items.length; 
    for (var i = 0; i < numItems; i++) { 
    console.log('ID: ' + resp.items[i].id + ' Content: ' + 
     resp.items[i].object.content); 
    } 
}); 

的在線工具來生成和測試查詢終點是那裏的Developer Page

生成和自定義查詢字符串追加到鏈接用戶我結束可以解析從終點返回的JSON,以檢查用戶活動流上是否共享了該特定鏈接。 的JSON返回這個樣子的 -

{ 
"items": [ 
    { 
    "title": "", 
    "published": "2015-06-12T16:39:11.176Z", 
    "url": "https://plus.google.com/+UserID/posts/PostID", 
    "object": { 
    "content": "", 
    "attachments": [ 
    { 
     "objectType": "article", 
     "url": "http://www.example.com" 
    } 
    ] 
    } 
    } 
] 
} 

如果與自定義查詢的鏈接,如果在返回的項目,瞧之一的附件部分!它已被分享。