如何查看用户在网站或网址上是否顶过(+1)google +按钮? [英] How to check user has liked(+1) google+ button on website or url?
问题描述
如何获得网站或网址上的google +按钮状态?我正在使用PHP.
How to get like status of google+ button on website or url? I am using PHP.
推荐答案
不幸的是,这不太可能. REST API和PlusOne按钮本身都不提供检查用户是否已对该页面+1的方法.此外,如果您使用的是PHP,则用户必须首先(使用OAuth)对自己进行身份验证,因此无论如何这可能不是您想要的.
Unfortunately this isn't quite possible. Neither the REST API nor the PlusOne button itselfs provides a method to check whether a user has +1'd the page or not. Furthermore, if you're using PHP, the user would have to authenticate himself first (using OAuth), so that's probably not what you want, anyway.
但是,您可以使用 JavaScript 来捕获当前访问者的操作.您可以在创建+1按钮时指定一个callback
参数,该参数将在用户单击+1按钮时每次调用(
What you can do, however, is using Javascript to catch actions of the current visitor. You can specify a callback
parameter when creating the +1 button which will be called everytime when the user clicks on the +1 button (source).
尽管这种方法无法为您提供有关用户身份的任何信息(就Google+用户而言),但是您可以使用Cookie或其他方式跟踪用户在服务器上的操作.或者,如果足够,只需在他逗留期间使用该信息即可.
While this approach doesn't provide you any information about who the user is (in terms of Google+ user), you could track his actions on your server using a cookie or something else. Or, if that's sufficient, just use the information for the duration of his stay.
这篇关于如何查看用户在网站或网址上是否顶过(+1)google +按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!