国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ?? ??? ?? ?? Force.com WeChat ?? ?? ?? ???? ?? 2?? ?? ??

Force.com WeChat ?? ?? ?? ???? ?? 2?? ?? ??

Mar 03, 2017 am 09:49 AM

?? 9? WeChat? Enterprise Account? ??? ? ???? ?? ??? ?????. ? ????? WeChat ?? ?? ??? ??? ??? ??? ???? ? ?? ?? ????? 2? ??? ???? ??? ??? ? ????.

?? ?? ?? ??:

?? ??? ?? ??? ??? ??? ? ??? ??? ???? ?? ????? ???? ?????. , ??? ?? ?? ??? ???? ?? ???? ????? ?????. ?????? Tencent? ??? ??? ????? ?? ??? ?? ??????? ??????. ?? ??? 90?? ?? ????. (??? ?? ??? ??? ?? ??? 1????.) ?????? ?? ??? ??? ???? ?? ?? Tencent??? ?? ?? ?? ???? ?? ???. ?? ?? ?? ?? ??? ??? ????. ???? Tencent? ??? ?? ?? ??? ???? ?? ?? ??? ??? ???.

http://qydev.weixin.qq.com/try ?t= experience

???? ?? ??:

?? ??? ?? ?? ????? ??? Tencent??? ??? ????? ?? ??? ? ????. ???? ??? ??? ?? ? + ??? ?? ?? ??? ???? ????. ??? ??? ?? ?? ???? ?? ???, ??? ??, ??? ??? ?? ?? ??? ?? ?? ??????. WeChat ID? ?? ????? ????? ??? HR ??????? ?? ??? ??? ??? ??? ??? ? ???, ???? ??? ?? ?? Excel ??? ???? ? Tencent Enterprise Account WeChat API? ?? ??? ?? ????. ???? ???? ??? ?? ??? ?????.


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證 > Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證??? ??? ?, ?? WeChat ID? QR ??? ???? ??? ? ????. ??? ?? ???? ???? ?? ?? ID ???? ???? ???? ?? ???? ????? ??? ?? ??? ???? ?????. ?? ?? ?? ?? ?????. ??? ???? ?? ?? ???? ???? ????? ?????. ?? ?? ??? ???? ???? ?????. ??? ?? ?? ??? ??? ?????? ?????.

Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

?? ???? Enterprise Account? ?? ????? ?? http://qydev.weixin.qq.com/wiki/index.phptitle=? ??? ? ????. %E5%85%B3%E6%B3%A8% E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8? Force.com?? ?? ???? ?????. ???. 2? ??? ?? ??? ??:

????? ???? ? ???? ???, ? ??? ??? ??? ????? ???? ? ???? ?? ?????. , ??? ?????? ??? ????. user ??? ?? user ? ???? 123? ???? ??? ??? ???? ???? ?????.


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證??? ?? ?? ???, ??? 2? ????? ??? ???? ???:

Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

?? ???? Enterprise Account ?? ????? ??? http://qydev.weixin? ??? ? ????. .qq.com/wiki/index.phptitle=%E5 %85%B3%E6%B3%A8%E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6% B3%A8? Force.com ????? ?? ???? ?????.

2? ??? ?? ??? ??:

????? ???? ? ???? ???? ????. ? ??? ??? ??? ????? ???? ?????. ??? ??? ??? ????. ???? user ??? ???? 123? ?????. ??? ??? ?? ???? ?????.


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

??? ?? EmployeeAuth?? ??? ??? ??? ????. ?? ??? apex ??? ????? ???? ??? ???? ????. ??? ?? 13?? ?? ??? ?? ??? ??? ??? ? ??? ??? ????? ????. , ???? ??? EmployeeAuthController? ??? ???? ?????.

<apex:page standardstylesheets="false" showHeader="false" sidebar="false" controller="EmployeeAuthController">
  <font size="50">
  <h1>Please input your user name and password</h1>
  </font>
  <font size="30">
  UserName: user<br />
  Password: 123<br /><br />
  <hr/>
  <apex:form >
  UserName: <apex:inputText size="100" style="height:100px" value="{!strUsername}" id="strUsername"/><br /><br />
  Password:   <apex:inputText size="100" style="height:100px" value="{!strPassword}" id="strPassword"/><br /><br />
  <center>
  <apex:commandButton value="Bind" style="width:600px; height:100px;font-size:50px" action="{!bind}" id="bind"  />
  </center>
  </apex:form>
  {!msg}
  </font>
</apex:page>

EmployeeAuthController ???? ???? ??? ???? ?? ?? WeChat? ??? ???????. 2? ??.

2? ?? ?? ? ????:

1. ??, ?? ?? ??(?? ????? ??? ?? ??)? ???? ??? ????? ??? ?? ???? ????:

Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

2. ??? ??:

???? ? ???? ???? ???? ??? ?? ????. open.weixin.qq.com ???? ??? ??? ???? ?? ??? ? ? ??? ?? ?? ???? 2? ???? ??? ??? URL? ??? ? code=CODE&state=STATE ????? ?????. ?? ??, ? ??? ? ?? ??? ?? ??? URL? http://johnson0001-developer-edition.ap1.force.com/EmployeeAuth?? Tencent openweixin.qq?? ?????. com ?? ?? http://johnson0001-developer-edition.ap1.force.com/EmployeeAuth?code=CODE&state=STATE???. Tencent? ??? ?? ????? ???? ???? ???? ????? ???? ????. ??? ?? code ???????. ? ????? ???? ??? userid? ???? Tencent? oauth2 ?????? ??? ? ????. userid? ?? ??? ?????. ?? ???? userid? ?????. ? ??? ID? ??? ???? ??? ?? ?? ?? ????.


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

3. ?? ??? ID? ???? ??? ?? Tencent oauth2 ?????? ?????.

? ?????? ?? ??? Tencent ??? http? ?????. ://qydev.weixin.qq.com/wiki/ index.phptitle=%E6%A0%B9%E6%8D%AEcode%E8%8E%B7%E5%8F%96%E6%88%90%E5% 91%98%E4%BF%A1%E6%81 %AF, ?? ???? ??? ? ????. ??? ??? ??? ??? ?? ??? ??? ???? ID???:


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

WeChat ?? ?? ??? ?? ?? ??? ?? ?? ?? ??? ??? ???? ??? ????. Tencent? API? ????? ???? ?? ???? ???? ???? ?? ??? ??? ????, ??? ??? ?? ?? ??? ?????? ????. ??? ??? Tencent ?? ??(http://qydev.weixin)? ?????. qq.com/wiki/index.php?title=%E4%B8%BB%E5%8A %A8%E8%B0%83%E7%94%A8 ??? ??? ??? ??? ?? ?? ??? ??? ?? ??????. ?? ?????:

https://qyapi.weixin.qq.com/cgi-bin/gettoken ?corpid=id&corpsecret=secret

Corpid? ? ??????? ?? ?? ? ????. ??? ?? ??? ??? ?????.


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

不過(guò)corpsecret就沒(méi)那么好找,實(shí)際是需要系統(tǒng)管理員在后臺(tái)創(chuàng)建管理組,創(chuàng)建管理組后就可以擁有相應(yīng)的Secret,而這個(gè)Secret所擁有的訪問(wèn)權(quán)限就是系統(tǒng)管理員創(chuàng)建的管理組所擁有的權(quán)限,騰訊文章http://qydev.weixin.qq.com/wiki/index.php?title=Secret也有提到:

Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

再回過(guò)頭來(lái)說(shuō)agentid騰訊文檔里提到指的是“跳轉(zhuǎn)鏈接時(shí)所在的企業(yè)應(yīng)用ID”,在本例里其實(shí)指的就是發(fā)送“身份驗(yàn)證”圖文消息的那個(gè)應(yīng)用也就是“企業(yè)小助手”的應(yīng)用ID,當(dāng)然在不同的用戶場(chǎng)景里可能會(huì)是不同的應(yīng)用在調(diào)用換取userid接口,如何查看“企業(yè)小助手”的應(yīng)用ID呢?進(jìn)到應(yīng)用中心,第一個(gè)就是企業(yè)小助手,點(diǎn)擊進(jìn)入就可以看到如下圖所示的企業(yè)應(yīng)用ID了:

Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

4. 二次驗(yàn)證

拿到userid后實(shí)際就可以進(jìn)行二次驗(yàn)證了,二次驗(yàn)證的方式有很多種,例如如果公司已經(jīng)建立起良好的通訊錄管理機(jī)制(userid等和企業(yè)人力資源數(shù)據(jù)庫(kù)同步,入職離職員工均能和企業(yè)號(hào)通訊錄同步),拿到userid后只要判斷這個(gè)userid是一位在職員工就可以自動(dòng)判斷為二次驗(yàn)證通過(guò),或者再保險(xiǎn)點(diǎn)如本例演示的,要求員工輸入公司的員工用戶名和密碼進(jìn)行驗(yàn)證。留意,輸入用戶名和密碼驗(yàn)證的頁(yè)面也就是我們前面提到的二次驗(yàn)證頁(yè)面是屬于企業(yè)擁有也是企業(yè)開發(fā)的,這樣就確保了企業(yè)對(duì)安全的控制,具體操作上,用戶輸入用戶名和密碼后企業(yè)可以調(diào)用已有的接口進(jìn)行驗(yàn)證,如果驗(yàn)證成功則將員工的userid等信息保存在業(yè)務(wù)系統(tǒng)數(shù)據(jù)庫(kù)中一遍后續(xù)操作。

5.通知騰訊關(guān)注成功

現(xiàn)在最后一步等企業(yè)在自己的網(wǎng)頁(yè)里完成了用戶驗(yàn)證后只剩下通知騰訊該用戶已經(jīng)驗(yàn)證成功讓相應(yīng)員工關(guān)注成功,此時(shí)應(yīng)該調(diào)用如下接口,可以看到接口需要的第二個(gè)參數(shù)即是我們前面換回來(lái)的userid:

https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?access_token=ACCESS_TOKEN&userid=USERID

此接口的詳細(xì)說(shuō)明如下:


Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證

二次驗(yàn)證的代碼實(shí)現(xiàn):

按照前面的思路,我們首先獲取從騰訊跳轉(zhuǎn)過(guò)來(lái)的code,并通過(guò)code換取用戶的userid,換取的這個(gè)過(guò)程在頁(yè)面加載中完成,為此主要代碼應(yīng)放在類構(gòu)造器里。下面的代碼里設(shè)置了五個(gè)變量,其中strPassword和strUsername和用戶在頁(yè)面里輸入的用戶名和密碼相對(duì)應(yīng),userID用來(lái)存儲(chǔ)換回來(lái)的userid信息,msg用來(lái)調(diào)試幫助在頁(yè)面里顯示中間信息,accessToken則用來(lái)存儲(chǔ)access token:

 public class EmployeeAuthController {

    public String strPassword { get; set; } 
    public String strUsername { get; set; }  
    public String msg { get; set; } 
    public String userID { get; set; } 
    public String accessToken { get; set; } 

    public EmployeeAuthController (){  
        accessToken = obtainAccessToken(); 
        String code = ApexPages.currentPage().getParameters().get(&#39;code&#39;); 
        //Obtain user ID 
         Http h = new Http(); 
         HttpRequest req = new HttpRequest(); 
         req.setMethod(&#39;GET&#39;); 
         req.setHeader(&#39;Accept-Encoding&#39;,&#39;gzip,deflate&#39;); 
         req.setHeader(&#39;Content-Type&#39;,&#39;text/xml;charset=UTF-8&#39;); 
         req.setHeader(&#39;User-Agent&#39;,&#39;Jakarta Commons-HttpClient/3.1&#39;);  
         req.setEndpoint(&#39;https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=&#39; + accessToken + &#39;&code=&#39; + code + &#39;&agentid=0&#39;); 
         String bodyRes = &#39;&#39;; 
         try{ 
            HttpResponse res = h.send(req); 
            bodyRes = res.getBody(); 
         } 
         catch(System.CalloutException e) { 
            System.debug(&#39;Callout error: &#39;+ e); 
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage())); 
         }    
         msg = bodyRes ; 
         //String operation to obtain userID: 
         JSONParser parser = JSON.createParser(bodyRes); 
         while(parser.nextToken() != null){ 
             if((parser.getCurrentToken() == JSONToken.FIELD_NAME)){ 
                 String fieldName = parser.getText(); 
                 parser.nextToken(); 
                 if(fieldName == &#39;UserId&#39;){ 
                     userID = parser.getText(); 
                 } 
             } 
         } 
         msg = userID; 
    }

}

上述代碼第9行調(diào)用obtainAccessToken方法獲取accessToken,后續(xù)會(huì)介紹該方法的詳情,accessToken兩個(gè)小時(shí)內(nèi)會(huì)失效,所以這里采取實(shí)時(shí)獲取的方式,當(dāng)然可以設(shè)計(jì)的再巧妙些以省卻每次實(shí)時(shí)獲取accessToken的網(wǎng)絡(luò)開銷。第10行獲得了從騰訊跳轉(zhuǎn)過(guò)來(lái)時(shí)帶的code參數(shù),從第11行通過(guò)HttpRequest方法來(lái)調(diào)用換取接口獲得userid,留意第18行指定了agentid為0,這是因?yàn)轵?yàn)證消息是從企業(yè)小助手應(yīng)用發(fā)起的,而企業(yè)小助手應(yīng)用id是0。第29行開始解析返回來(lái)的JSON數(shù)據(jù)獲取userid。

下面是obtainAccessToken方法,方法內(nèi)容也比較直接,主要通過(guò)調(diào)用gettoken接口來(lái)獲取accessToken,并通過(guò)JSONParser類來(lái)解析返回的JSON數(shù)據(jù)以獲得accessToken:

 private String obtainAccessToken(){ 
        String token; 
         Http h = new Http(); 
         HttpRequest req = new HttpRequest(); 
         req.setMethod(&#39;GET&#39;); 
         req.setHeader(&#39;Accept-Encoding&#39;,&#39;gzip,deflate&#39;); 
         req.setHeader(&#39;Content-Type&#39;,&#39;text/xml;charset=UTF-8&#39;); 
         req.setHeader(&#39;User-Agent&#39;,&#39;Jakarta Commons-HttpClient/3.1&#39;); 
         req.setEndpoint(&#39;https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wx548178d7f347f582&corpsecret=9pwWy0AVoT6V65hnwZLYdi4jnLLx65ofBRb_Ds0mAozysQoywDaqbqYCqglm2vhr&#39;); 
         String bodyRes = &#39;&#39;; 
         try{ 
            HttpResponse res = h.send(req); 
            bodyRes = res.getBody(); 
         } 
         catch(System.CalloutException e) { 
            System.debug(&#39;Callout error: &#39;+ e); 
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage())); 
         }    
         msg = bodyRes; 
         JSONParser parser = JSON.createParser(bodyRes); 
         while(parser.nextToken() != null){ 
             if((parser.getCurrentToken() == JSONToken.FIELD_NAME)){ 
                 String fieldName = parser.getText(); 
                 parser.nextToken(); 
                 if(fieldName == &#39;access_token&#39;){ 
                     token= parser.getText(); 
                 } 
             } 
         } 
         msg = token; 
         return token; 
    }

接下來(lái)最重要的方法是bind方法,該方法將負(fù)責(zé)用戶身份驗(yàn)證以及通知騰訊用戶關(guān)注成功,可以看到下面代碼里第2行到第6行只做了很簡(jiǎn)單的用戶名密碼校驗(yàn),真實(shí)場(chǎng)景里可以根據(jù)企業(yè)的具體認(rèn)證機(jī)制進(jìn)行替換,從第9行開始也即企業(yè)內(nèi)部用戶認(rèn)證通過(guò)后開始調(diào)用authsucc接口通知騰訊用戶關(guān)注成功。

 public PageReference bind() {  
        if(!strUsername.equals(&#39;user&#39;)){ 
            msg = &#39;Please input correct user name&#39;;  
        } 
        else if(!strPassword.equals(&#39;123&#39;)){ 
            msg = &#39;Please input correct password&#39;;  
        } 
        else{ 
            msg = &#39;Bind successfully!&#39;; 
            //Notify tencent to add user 
            Http h = new Http(); 
            HttpRequest req = new HttpRequest(); 
            req.setMethod(&#39;GET&#39;); 
            req.setHeader(&#39;Accept-Encoding&#39;,&#39;gzip,deflate&#39;); 
            req.setHeader(&#39;Content-Type&#39;,&#39;text/xml;charset=UTF-8&#39;); 
            req.setHeader(&#39;User-Agent&#39;,&#39;Jakarta Commons-HttpClient/3.1&#39;); 
            req.setEndpoint(&#39;https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?access_token=&#39; + accessToken + &#39;&userid=&#39; + userID); 
            String bodyRes = &#39;&#39;; 
             try{ 
                HttpResponse res = h.send(req); 
                bodyRes = res.getBody(); 
             } 
             catch(System.CalloutException e) { 
                System.debug(&#39;Callout error: &#39;+ e); 
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage())); 
             }    
             msg = bodyRes ;  
               } 
    }

?更多Force.com微信企業(yè)號(hào)開發(fā)系列- 啟用二次驗(yàn)證相關(guān)文章請(qǐng)關(guān)注PHP中文網(wǎng)!

?

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???