公眾號第三方平台開發 教程六 代公眾號使用JS SDK說明

來源:互聯網
上載者:User

標籤:

公眾號第三方平台開發 教程一 建立公眾號第三方平台

公眾號第三方平台開發 教程二 component_verify_ticket和accessToken的擷取

公眾號第三方平台開發 教程三 公眾號授權第三方平台

公眾號第三方平台開發 教程四 代公眾號發起網頁授權說明

公眾號第三方平台開發 教程五 代公眾號處理訊息和事件

公眾號第三方平台開發 教程六 代公眾號使用JS SDK說明

另,感謝一下這個大蝦的部落格,這幾篇東西都是在他的博文基礎上完成的,他的部落格裡也有一些介面代碼可以下載
開發系列教程

 

 

 

 

 

這一部分重點講一下配置,其他的東西直接看官方文檔就好了

擷取jsapi_ticket的函數

    /// <summary>    /// 擷取jsapi_ticket    /// </summary>    /// <returns></returns>    private string GetTicket()    {        string ticket = string.Empty;        Member_Model memberInfo = Member_BLL.GetModelByKeyFiled(memberID);        string token = memberInfo.authorizerAccessToken;        appID = memberInfo.authorizerAppid;     //這裡用的是服務方的PPID,不是公眾號的APPID        string result = Post("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + token + "&type=jsapi", "");        JObject objResult = (JObject)JsonConvert.DeserializeObject(result);        ticket = objResult.Value<string>("ticket");        return ticket;    }
signature的產生
    private void Bind()    {        WeiXinInterface.RefreshAndUpdateToken(memberID);            //重新整理服務方的token        timestamp = ConvertDateTimeInt(DateTime.Now).ToString();    //時間戳記        noncestr = GenerateNoncestr(16);                            //隨機產生的字串        ticket = GetTicket();        string url = "http://****/jspage.aspx?memberID=" + memberID;  //*號部分各位替換成自己的網域名稱        string tempStr = string.Format("jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}", ticket, noncestr, timestamp, url);        LogTool.LogToDirDest(filePath, LogType.Debug, pageUrl + " 擷取到的明文:" + tempStr);        signature = System.Web.Security.FormsAuthentication.         HashPasswordForStoringInConfigFile(tempStr, "sha1").ToLower();        LogTool.LogToDirDest(filePath, LogType.Debug, pageUrl + " 擷取到的signature:" + signature);        //Response.Write(testStr);    }

前台JS頁面配置




公眾號第三方平台開發 教程六 代公眾號使用JS SDK說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.