gpt4 book ai didi

php - 如何使用php自动发布到google+

转载 作者:可可西里 更新时间:2023-11-01 00:45:29 27 4
gpt4 key购买 nike

当我在我的网站上创建帖子或其他内容时,我想在我的 Google Plus 中发布

我在 Google API 中进行了搜索,但找不到好东西。

如果你有什么有用的分享。谢谢。

最佳答案

这样你就必须自己分享它,它不会自动分享,因为我还没有抽出时间实际这样做,但你可以通过打开 javascript 按钮来发布它。

function getPlus($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
curl_setopt($curl, CURLOPT_POST, 1);
curl_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"}]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$curl_results = curl_exec ($curl);
curl_close ($curl);
$json = json_decode($curl_results, true);
return intval( $json[0]['result']['metadata']['globalCounts']['count'] );
}

这是打开窗口的按钮。

<a
href="https://plus.google.com/share?url=<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>"
onClick="return google_click(400, 300)" target="_blank"
title="Share This on Google+"
>Share on Google+</a>

和 javascript。

<script type="text/javascript" defer="defer">
function google_click(width, height)
{
var leftPosition, topPosition;
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
var u=location.href;
var t=document.title;
window.open('https://plus.google.com/share?url='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
return false;
}
</script>

关于php - 如何使用php自动发布到google+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20365309/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com