Is there a Google Plus Comments plugin ? (Like Facebook Social Comments, DISQUS or IntenseDebate)?

StackOverflow https://stackoverflow.com/questions/9319164

문제

I was wondering and trying to find a Google Plus plugin, like Facebook have, like DISQUS or IntenseDebate?

Anyone knows if there is one or have an idea of how to do one using Google+ API?

도움이 되었습니까?

해결책

<script src="https://apis.google.com/js/plusone.js">
</script>
<div class="g-comments"
    data-href="http://stackoverflow.com"
    data-width="580"
    data-first_party_property="BLOGGER"
    data-view_type="FILTERED_POSTMOD">
</div>

https://jsfiddle.net/fdyuhp90/1/

Without API Key

다른 팁

Yes, since several months there is a Wordpress plugin available.

Follow this link: http://wordpress.org/plugins/gplus-comments/

No official comments plugin exists at this time, but you can use the REST APIs to access comments that have been made on public posts via the comments.list method.

This means that if you share a page on Google+ via a public activity, you can use the APIs to list all of the comments made to that activity on Google+ and then render them in your page. You can then link visitors to the activity thereby allowing them to participate in the conversation.

I've seen a few implementations of this technique. Here is a JavaScript implementation that's designed to drop into a static HTML blog. I won't reproduce the whole entry here, since it's pretty involved, but the gist of what you need to do is:

  1. Get an API key to access the Google+ APIs
  2. Embed the ID of the public activity into your document. In the linked example stashes it into the class of a div.
  3. Use the JSONP interface of the REST APIs to fetch the comments for that activity. If one page of comments is sufficient, this is a one liner.

https://www.googleapis.com/plus/v1/activities/_somePublicActivityId_/comments?key=_yourApiKey_&callback=myawesomecallback

  1. From your callback function print the comments somewhere in the page.

    function myawesomecallback(resposneJson) {
      var activity = resposneJson.items[0].inReplyTo[0];
      var comments = resposneJson.items;
    
      //find element to insert into
      var insertionElements = document.getElementsByClassName('g-comments-for ' + activity.id);
      var insertionElement = insertionElements[0];
    
      var newContents = "";
      for(i=0; i<comments.length; i++) {
        var actor = comments[i].actor;
    
        var commentBody = comments[i].object.content;
    
        //do the insertion
        newContents += "<dt><a href='" + actor.url + 
          "'><img src='" + actor.image.url + "' /></a></dt>" + 
          "<dd><a href='" + actor.url + "'>" + actor.displayName + 
          "</a>: " + commentBody + "</dd>";
      }
      insertionElement.innerHTML = "<dl>" + newContents + 
        "</dl> <p class='g-commentlink'>Please comment on the <a href='" + 
        activity.url + "'>Google+ activity</a></p>";   
    }
    

No, the Google+ API is currently entirely read-only, and it doesn't have a comments plugin like Facebook does.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top