FB.ui Feed完整示例

//该方法用于乱码时转码

function encode(str)
 {
  var len = str.length;
  var scill='';
  var isSkip=false;
  for(var i=0;i<len;i++)
  {
   if(str.charAt(i)=="<")
   {
    isSkip=true;
   }
   if(isSkip)
   {
    scill += str.charAt(i);
   }else{
    scill += "&#"+str.charCodeAt(i)+";";
   }
   if(str.charAt(i)==">")
   {
    isSkip = false;
   }
  } 
  return scill;
 }

 

FB.ui(
        {
          method: 'stream.publish',        
          message: ‘玩家可输入的文字’,
          uid: ‘用户的FBID’,
          target_id: ‘接收方的FBID’,
          attachment: {
            name: 'Feed名称',
            caption: '标题',
            href: '名称链接',
            description: ('描述'),
            properties: {
              '子链接1':{ text: '子链接文字', href: '子链接URL'},
              '子链接2':{ text: '子链接文字', href: '子链接URL'},
              '子链接3':{ text: '子链接文字', href: '子链接URL'},
          },           
            media: [
                    {
                    'type':'image',
                    'src':'图片地址',
                    'href':'图片链接URL'
                    }
                ]
         },
          action_links: [
            { text: '右下角链接文字', href: '右下角链接URL'}          ]
        },
        function(response) {
          if (response && response.post_id) {
            alert('Post was published.');
          } else {
            alert('Post was not published.');
          }
        }
      );

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值