我正在使用Gigya的JavaScript API来设置社交共享栏,但需要自定义图标。似乎showShareBarUI不允许facebook / twitter /等。要更改的图标,但它允许用户预览他们将发布的帖子。相反,publishUserAction将允许自定义图标通过登录发布,但不会提供用户内容的任何预览。
在使用Gigya时,有没有办法为共享栏设置自定义图标并预览帖子内容?
我正在尝试两者:
var act = new gigya.socialize.UserAction();
act.setTitle("This is my title"); // Setting the Title
act.setLinkBack("http://www.gigya.com"); // Setting the Link Back
act.setDescription("This is my Description"); // Setting Description
act.addActionLink("Read More", "http://www.gigya.com"); // Adding Action Link
var params =
{
userAction:act,
shareButtons:[
{ // Twitter Tweet button
provider:'twitter-tweet',
tooltip:'Share on Twitter',
defaultText:'Twitter message'
},
{ // Google +1 button
provider:'google-plusone',
tooltip:'Recommend this on Google',
userMessage:'default user message'
}
],
showCounts:'none',
containerID:'shareBar'
}
gigya.socialize.showShareBarUI(params);
或 -
function twitterLogin() {
gigya.services.socialize.login({provider:'twitter',callback:twitter});
}
function twitter(){
var act = new gigya.socialize.UserAction();
act.setTitle("This is my title"); // Setting the Title
act.setLinkBack("http://www.gigya.com"); // Setting the Link Back
act.setDescription("This is my Description"); // Setting Description
act.addActionLink("Read More", "http://www.gigya.com"); // Adding Action Link
var params =
{
userAction:act,
enabledProviders:"twitter"
};
// Publishing the User Action
gigya.socialize.publishUserAction(params);
}
HTML -
<div id="shareBar" >
<a href="#" onclick="javascript:twitterLogin()">
<img src="images/custom-twitter-icon.png" />
</a>
</div>
答案 0 :(得分:2)
因此,经过多个小时的努力,解决方案令人沮丧,因为它非常容易并且在showShareBarUI页面上,但没有以任何方式强调。
对于自定义共享栏图标,您必须使用Gigya样式按钮名称而不是保留的提供程序名称。所以使用&#39; twitter&#39;不是推特推特&#39; ...
var params =
{
userAction:act,
shareButtons:[
{ // Twitter Tweet button
provider:'twitter',
tooltip:'Share on Twitter',
defaultText:'Twitter message'
},
],
showCounts:'none',
containerID:'shareBar'
}
gigya.socialize.showShareBarUI(params);