{"id":273,"date":"2015-04-06T13:31:54","date_gmt":"2015-04-06T13:34:45","guid":{"rendered":"https:\/\/0fe4dgoogle-plus-1.jpg"},"modified":"2015-07-16T15:09:52","modified_gmt":"2015-07-16T21:09:52","slug":"obtener-el-numero-de-1-de-google-para-una-url","status":"publish","type":"post","link":"https:\/\/emanuelpaxtian.com\/blog\/obtener-el-numero-de-1-de-google-para-una-url\/","title":{"rendered":"Obtener el numero  de +1 de Google+ para una URL"},"content":{"rendered":"<p>Sencilla funci\u00f3n PHP usando CURL y JSON para obtener el n\u00famero total de +1 de google plus de una determinada url:<\/p>\n<pre class=\"brush:php\">function total_googleplus($url){\r\n\t$curl = curl_init();\r\n\tcurl_setopt($curl, CURLOPT_URL, \"https:\/\/clients6.google.com\/rpc\");\r\n\tcurl_setopt($curl, CURLOPT_POST, true);\r\n\tcurl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);\r\n\tcurl_setopt($curl, CURLOPT_POSTFIELDS, '[{\"method\":\"pos.plusones.get\",\"id\":\"p\",\"params\":{\"nolog\":true,\"id\":\"'.rawurldecode($url).'\",\"source\":\"widget\",\"userId\":\"@viewer\",\"groupId\":\"@self\"},\"jsonrpc\":\"2.0\",\"key\":\"p\",\"apiVersion\":\"v1\"}]');\r\n\tcurl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\r\n\tcurl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application\/json'));\r\n\t$curl_results = curl_exec ($curl);\r\n\tcurl_close ($curl);\r\n\t$json = json_decode($curl_results, true);\r\n\treturn isset($json[0]['result']['metadata']['globalCounts']['count'])?intval( $json[0]['result']['metadata']['globalCounts']['count'] ):0;\r\n}\r\n \r\necho total_googleplus('http:\/\/www.bufa.es');\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sencilla funci\u00f3n PHP usando CURL y JSON para obtener el n\u00famero total de +1 de google plus de una determinada url: function total_googleplus($url){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, &#8220;https:\/\/clients6.google.com\/rpc&#8221;); curl_setopt($curl,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":335,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":0,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media\/335"}],"wp:attachment":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}