zoukankan      html  css  js  c++  java
  • 新浪微博--分享到微博的简单使用

    新浪微博
    分享到微博方法,以下均为新浪微博提供的JS方法(我用的是.net平台)

    方法1:

      这个方法比较简单,只需要在你想放分享到微博的地方放入一下代码就可以了:
      <script type="text/javascript" charset="utf-8">
      (function(){
      var _w = 72 , _h = 16;
      var param = {
        url:location.href,
        type:'3',
        count:'1', /**是否显示分享数,1显示(可选)*/
        appkey:'', /**您申请的应用appkey,显示分享来源(可选)*/
        title:'新浪微博分享API测试', /**分享的文字内容(可选,默认为所在页面的title)*/
        pic:'', /**分享图片的路径(可选)*/
        ralateUid:'', /**关联用户的UID,分享微博会@该用户(可选)*/
        language:'zh_cn', /**设置语言,zh_cn|zh_tw(可选)*/
        dpc:1
      }
      var temp = [];
      for( var p in param ){
        temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
      }
      document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://service.weibo.com/staticjs/weiboshare.html?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>')
    })()
    </script>


    方法2:

      步骤一:在页面html标签里加入:xmlns:wb="http://open.weibo.com/wb"

      步骤二:引用新浪微博的JS:<script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=" type="text/javascript" charset="utf-8"></script>

      步骤三:引用新浪微博的icon或button
      <wb:share-button type="icon" size="small" pic="" count="y"  title="新浪微博分享test" language="zh_ch" >分享到新浪微博</wb:share-button>


      新浪微博提供以下具体的参数可供设置:
     
      名称           类型           默认值        是否必选           描述

      url            String         无            否                 分享页面链接
     
      type         String         icon          否                 按钮样式,button|icon

      size          String         small         否                 按钮尺寸:big|middle|small

      count       String          y             否                 显示分享数: y|n

      title          String         无            否                 分享的文字内容(可选,默认为所在页面的title)

      pic            String        无            否                 分享图片的路径(可选),多张图片通过"||"分开。

      searchPic   Boolean     true           否                 是否要自动抓取页面上的图片。true|falsetrue:自动抓取,false:不自动抓取。

      language   String        zh_ch          否                 语言设置:zh_cn|zh_tw
     
      width          Number      无             否                 指定宽度

      height         Number     无             否                 指定高度,根据按钮样式的不同而不同

      appkey         String      无             否                 显示微博信息来源

  • 相关阅读:
    树莓派关闭swap文件[浙大嵌入式系统]
    树莓派之objdump [浙大嵌入式系统]
    树莓派RAM[浙大嵌入式系统]
    温湿度传感器dht11的lcd显示[嵌入式系统]
    ucos II[嵌入式系统]
    MooTools 1.4 源码分析 Fx.CSS
    MooTools 1.4 源码分析 (关于Core、Type等模块分析)
    MooTools 1.4 源码分析 Fx.Tween
    MooTools Class.Mutators 如何建立一个我们自己的Mutator
    Javascript各种循环测试,达夫设备可用性分析
  • 原文地址:https://www.cnblogs.com/huyueping/p/3154359.html
Copyright © 2011-2022 走看看