zoukankan      html  css  js  c++  java
  • 电信能力开放短信api调用

    相关网址http://www.ctopen.cn

    按找官方相关文档 就是调用不成功 老是反回-10004$$$无效的认证码$

    账号注册通过了 1元体验短信 能力也买了 

    冒失都是按他的格式传递的 怎么就是错误呢 郁闷

    看样子只能等这周他公布sdk后在测试了

    代码
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Security.Cryptography;
    using System.Web;
    using System.Net;
    代码
            int APID = 10000;//你的apid
            string APUserAccount = "cjiang";//你的用户名
            int FunID = 10000033;
            
    string TimeStamp = "2525189787131";
            
    string Authenticator = string.Empty;
            
    string APKEY = "ed990760c1cb48dd9cd26476f4838fa8";////你的key
            string AuthRequestValue = string.Empty;
            
    string AuthResponse = string.Empty;

    private void button1_Click(object sender, EventArgs e)
            {
                SendMsg();
            }


            
    public void SendMsg()
            {
               
           
                
    string sha = MD5OrSHA1(TimeStamp + "$" + APID + "$" + APUserAccount + "$" + FunID + "$" + APKEY, "SHA1");
               Authenticator
    = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sha));
              AuthRequestValue 
    =TimeStamp + "$" + APID+ "$" + APUserAccount + "$" + FunID + "$" +HttpUtility.UrlEncode(Authenticator);
              
    string url = "http://www.ctopen.cn/InterfaceForAP/Auth.aspx?AuthRequest=" + AuthRequestValue;

             
              HttpWebRequest req 
    = (HttpWebRequest)HttpWebRequest.Create(url);
              req.Method 
    = "GET";
              req.KeepAlive 
    = false;
                
    // 接收返回的页面
             HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
             System.IO.Stream responseStream 
    = resp.GetResponseStream();
             System.IO.StreamReader reader 
    = new System.IO.StreamReader(responseStream,Encoding.UTF8);
             AuthResponse 
    = reader.ReadToEnd();
             textBox1.Text 
    = AuthResponse;

            }
            
    private static string MD5OrSHA1(string Value, string EncryptType)
            {
                
    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Value, EncryptType);
            }

     按照相关的说明 可能是 Authenticator 这里sha1 和base64加密错误了

     老是反回-10004$$$无效的认证码$

    最后测试 发现不能加base64 直接sha1过去通过 饿滴神啊

  • 相关阅读:
    ADB命令大全
    Backup your Android without root or custom recovery -- adb backup
    Content portal for Pocketables Tasker articles
    Is there a way to detect if call is in progress? Phone Event
    Tasker to proximity screen off
    Tasker to detect application running in background
    Tasker to create toggle widget for ES ftp service -- Send Intent
    Tasker to proximity screen on
    Tasker to answer incoming call by pressing power button
    Tasker to stop Poweramp control for the headset while there is an incoming SMS
  • 原文地址:https://www.cnblogs.com/jcgh/p/1619316.html
Copyright © 2011-2022 走看看