duanba3707
2014-05-29 12:29
浏览 46

适用于Twitter和Google Plus的纯Javascript API

Using this code I can share to Facebook using just Javascript and my own UI buttons/links etc.

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');
        }
    }
); 

Do Twitter and Google Plus have something similar? At the moment I'm needing to use their HTML, and therefore their styling. I'd like to be able to style the "share" options I have to match the site I'm working on.

If it isn't possible through just Javascript is it possible using PHP? I'm thinking I could do an Ajax call to share the page if PHP could do this.

图片转代码服务由CSDN问答提供 功能建议

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

  FB.init({
 appId:'MyAppId',
 xfbml:true,
 version:'v2.0'
}); 
 
 // In 我的.click()方法)
FB.ui(
 {
方法:'share',
 href:document.URL,
},
函数(响应){
 log(response); \  n if(typeof response!='undefined'){
 alert('谢谢分享'); 
} 
} 
};  
   
 
 

Twitter和Google Plus有类似的东西吗? 目前我需要使用他们的HTML,因此他们的样式。 我希望能够设置我所拥有的“共享”选项,以匹配我正在处理的网站。

如果通过Javascript无法实现,是否可以使用PHP? 我想我可以做一个Ajax调用来共享页面,如果PHP可以做到这一点。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongque8332 2014-05-29 16:38
    已采纳

    Google+ has a JavaScript API that supports all of their existing API functionality. However Google+ does not allow posting without using their button and UI. The exceptions being if you want to use app activities or are only going to be used by Google Apps accounts.

    Twitter had a JavaScript API that they stopped supporting in 2013. To post to Twitter you will have to proxy requests through your own server.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题