Pure Javascript API for Twitter and Google Plus


Pure Javascript API for Twitter and Google Plus

使用此代码,我可以使用Javascript和我自己的UI按钮/链接等分享到Facebook。

FB.init({
    appId      : 'MyAppId',
    xfbml      : true,
    version    : 'v2.0'
});
//In my .click() method)
FB.ui(
    {
        method: 'share',
        href: document.URL,
    }, 
    function(response){
        log(response);
        if (typeof response != 'undefined') {
            alert('Thanks for sharing');
        }
    }
); 

Twitter和Google Plus有相似之处吗?目前我需要使用他们的HTML,因此也需要使用他们的样式。我想能够样式的"共享"选项,我必须匹配我正在工作的网站。

如果它不可能通过Javascript是可能使用PHP吗?我想我可以做一个Ajax调用来共享页面如果PHP可以做到的话

Google+有一个JavaScript API,支持他们现有的所有API功能。然而,Google+不允许在不使用按钮和UI的情况下发帖。例外情况是,如果你想使用应用程序活动或只打算由谷歌应用程序帐户使用。

Twitter在2013年停止了对JavaScript API的支持。要在Twitter上发帖,你必须通过自己的服务器代理请求。