注:

1、下文中所有HTTP请求所指的Host都是f.10086.cn

2、目前只有中国移动用户可以使用

1、打开登录页面:GET /huc/user/space/login.do?m=submit&fr=space,获取两个cookie值:JSESSIONID和UUID
2、登录:POST /huc/user/space/login.do,数据为手机号码和密码:mobilenum=your_phone_number&password=your_fetioon_password&m=submit&backurl=http%3A%2F%2Ff.10086.cn%2F&fr=space,获取cookie值:Set-Cookie: cell_cookie,注意:登录时,需要携带header:Content-Type: application/x-www-form-urlencoded,否则会触发验证码检查
2.1、上述步骤2会重定向到其他路径:Location: http://f.10086.cn/?nuc_id=5cb9e9eca65e2bc2875a6fe55869daa1,4e8cbe602e50b189ddc33e51de704474,e017a7e72b081563f1fbf1263d2fd8f8,1
2.2、http://f.10086.cn/?nuc_id=5cb9e9eca65e2bc2875a6fe55869daa1,4e8cbe602e50b189ddc33e51de704474,e017a7e72b081563f1fbf1263d2fd8f8,1<----这个会继续重定向到Location: http://f.10086.cn/wap2.jsp,同时会重置cookie值:JSESSIONID。wap2.jsp是一个新闻综合网页。
3、发送消息:POST /im/user/sendMsgToMyselfs.action HTTP/1.1,数据:msg=A hello word short message
3.1、上述步骤可能会被重定向到Location: http://f.10086.cn/im/login/cklogin.action?t=1420875966727,此时可以重新POST /im/user/sendMsgToMyselfs.action HTTP/1.1,即可发送成功。

一下是使用MFC Wininet实现的Demo,在本文章发布时,还是可以发送短信的

另外,代码没有经过锤炼,请不要在意内存泄露等bug。。。

#define FE_BUFFER_SIZE (1024*1024)

void do_me()
{
HINTERNET hSessHnd;
HINTERNET hConnHnd;
HINTERNET hRqstHnd;
BOOL bRqstRet;
BOOL bQueryRet;
BOOL bReadRet;
UCHAR* pucBuffer = new UCHAR[FE_BUFFER_SIZE];
DWORD dwBufferLen;
DWORD dwReadLen;
DWORD dwIndex; //使用fiddler代理
hSessHnd = InternetOpenA("FetionMsg", INTERNET_OPEN_TYPE_PROXY, "http=http://127.0.0.1:8888", NULL, 0);
//直接登录
//hSessHnd = InternetOpenA("FetionMsg", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (NULL == hSessHnd)
{
printf("InternetOpenA failed\r\n");
return;
} hConnHnd = InternetConnectA(hSessHnd, "f.10086.cn", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if (NULL == hConnHnd)
{
printf("InternetConnectA failed.\r\n");
return;
} hRqstHnd = HttpOpenRequestA(hConnHnd, "GET", "huc/user/space/login.do?m=submit&fr=space", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
if (NULL == hRqstHnd)
{
printf("HttpOpenRequestA failed.\r\n");
return;
} bRqstRet = HttpSendRequestA(hRqstHnd, NULL, 0, NULL, 0);
if (TRUE != bRqstRet)
{
printf("HttpSendRequestA failed\r\n");
return;
} ZeroMemory(pucBuffer, FE_BUFFER_SIZE);
dwBufferLen = FE_BUFFER_SIZE;
dwIndex = 0;
bQueryRet = HttpQueryInfoA(hRqstHnd, HTTP_QUERY_CONTENT_LENGTH, pucBuffer, &dwBufferLen, &dwIndex);
if (TRUE == bQueryRet)
{
printf("1: len = %s, %u\r\n", pucBuffer, dwBufferLen);
bReadRet = InternetReadFile(hRqstHnd, pucBuffer, FE_BUFFER_SIZE, &dwReadLen);
printf("1 read ret=%u, len=%u\r\n", bReadRet, dwReadLen);
printf("--------\r\n");
printf("%s", pucBuffer);
printf("--------\r\n");
}
else
{
printf("1 no response body\r\n");
} InternetCloseHandle(hRqstHnd); hRqstHnd = HttpOpenRequestA(hConnHnd, "POST", "huc/user/space/login.do", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
if (NULL == hRqstHnd)
{
printf("HttpOpenRequestA 2 failed.\r\n");
return;
}
HttpAddRequestHeadersA(hRqstHnd, "Content-Type: application/x-www-form-urlencoded\r\n", -1, HTTP_ADDREQ_FLAG_ADD); const char* pcLoginData = "mobilenum=your_number&password=your_fetion_password&m=submit&backurl=http%3A%2F%2Ff.10086.cn%2F&fr=space";
bRqstRet = HttpSendRequestA(hRqstHnd, NULL, 0, (VOID*)pcLoginData, strlen(pcLoginData));
if (TRUE != bRqstRet)
{
printf("HttpSendRequestA 2 failed\r\n");
return;
} ZeroMemory(pucBuffer, FE_BUFFER_SIZE);
dwBufferLen = FE_BUFFER_SIZE;
dwIndex = 0;
bQueryRet = HttpQueryInfoA(hRqstHnd, HTTP_QUERY_CONTENT_LENGTH, pucBuffer, &dwBufferLen, &dwIndex);
if (TRUE == bQueryRet)
{
printf("2: len = %s, %u\r\n", pucBuffer, dwBufferLen);
bReadRet = InternetReadFile(hRqstHnd, pucBuffer, FE_BUFFER_SIZE, &dwReadLen);
printf("2 read ret=%u, len=%u\r\n", bReadRet, dwReadLen);
printf("--------\r\n");
printf("%s", pucBuffer);
printf("--------\r\n");
}
else
{
printf("2 no response body\r\n");
}
InternetCloseHandle(hRqstHnd); hRqstHnd = HttpOpenRequestA(hConnHnd, "POST", "im/user/sendMsgToMyselfs.action", "HTTP/1.1", NULL, NULL, 0, 0);
if (NULL == hRqstHnd)
{
printf("HttpOpenRequestA 3 failed.\r\n");
return;
} const char* pcMsgData = "msg=HelloWorld";
bRqstRet = HttpSendRequestA(hRqstHnd, NULL, 0, (VOID*)pcMsgData, strlen(pcMsgData));
if (TRUE != bRqstRet)
{
printf("HttpSendRequestA 3 failed\r\n");
return;
}
ZeroMemory(pucBuffer, FE_BUFFER_SIZE);
dwBufferLen = FE_BUFFER_SIZE;
dwIndex = 0;
bQueryRet = HttpQueryInfoA(hRqstHnd, HTTP_QUERY_CONTENT_LENGTH, pucBuffer, &dwBufferLen, &dwIndex);
if (TRUE == bQueryRet)
{
printf("3: len = %s, %u\r\n", pucBuffer, dwBufferLen);
bReadRet = InternetReadFile(hRqstHnd, pucBuffer, FE_BUFFER_SIZE, &dwReadLen);
printf("3 read ret=%u, len=%u\r\n", bReadRet, dwReadLen);
printf("--------\r\n");
printf("%s", pucBuffer);
printf("--------\r\n");
}
else
{
printf("3 no response body\r\n");
} InternetCloseHandle(hRqstHnd); hRqstHnd = HttpOpenRequestA(hConnHnd, "POST", "im/user/sendMsgToMyselfs.action", "HTTP/1.1", NULL, NULL, 0, 0);
if (NULL == hRqstHnd)
{
printf("HttpOpenRequestA 3 failed.\r\n");
return;
}
HttpAddRequestHeadersA(hRqstHnd, "Content-Type: application/x-www-form-urlencoded\r\n", -1, HTTP_ADDREQ_FLAG_ADD);
bRqstRet = HttpSendRequestA(hRqstHnd, NULL, 0, (VOID*)pcMsgData, strlen(pcMsgData));
if (TRUE != bRqstRet)
{
printf("HttpSendRequestA 3 failed\r\n");
return;
}
ZeroMemory(pucBuffer, FE_BUFFER_SIZE);
dwBufferLen = FE_BUFFER_SIZE;
dwIndex = 0;
bQueryRet = HttpQueryInfoA(hRqstHnd, HTTP_QUERY_CONTENT_LENGTH, pucBuffer, &dwBufferLen, &dwIndex);
if (TRUE == bQueryRet)
{
printf("3: len = %s, %u\r\n", pucBuffer, dwBufferLen);
bReadRet = InternetReadFile(hRqstHnd, pucBuffer, FE_BUFFER_SIZE, &dwReadLen);
printf("3 read ret=%u, len=%u\r\n", bReadRet, dwReadLen);
printf("--------\r\n");
printf("%s", pucBuffer);
printf("--------\r\n");
}
else
{
printf("3 no response body\r\n");
} printf("All OK!\r\n"); InternetCloseHandle(hRqstHnd);
InternetCloseHandle(hConnHnd);
InternetCloseHandle(hSessHnd);
}

  

调用飞信HTTP接口给自己发短信的更多相关文章

  1. 用Python调用华为云API接口发短信

    [摘要] 用Python调用华为云API接口实现发短信,当然能给调用发短信接口前提条件是通过企业实名认证,而且有一个通过审核的短信签名,话不多说,showcode #!/usr/bin/python3 ...

  2. iOS开发之调用系统打电话发短信接口以及程序内发短信

    在本篇博客开头呢,先说一下写本篇的博客的原因吧.目前在做一个小项目,要用到在本应用程序内发验证码给其他用户,怎么在应用内发送短信的具体细节想不大起来了,于是就百度了一下,发现也有关于这方面的博客,点进 ...

  3. iOS基本的发短信和打电话调用

    电话.短信是手机的基础功能,iOS中提供了接口,让我们调用.这篇文章简单的介绍一下iOS的打电话.发短信在程序中怎么调用. 1.打电话 [[UIApplication sharedApplicatio ...

  4. ios打电话发短信接口

    电话.短信是手机的基础功能,iOS中提供了接口,让我们调用.这篇文章简单的介绍一下iOS的打电话.发短信在程序中怎么调用. 1.打电话 [[UIApplication sharedApplicatio ...

  5. ios 设置亮度、声音;调用发短信、邮件、打电话

    一,设置亮度 [[UIScreen mainScreen] setBrightness:0.5];//0.0~1.0 二,设置声音 1,添加 MediaPlayer.framework 框架 2,在需 ...

  6. iOS 打电话、发短信、邮件、打开网址、调用应用等合集

    iOS中的很多功能都是非常简单的,几行代码就搞定了,比如打电话.打开网址.发邮件.发短信等,这里总结几个比较常用的: 1.打电话 方式一:最简单最直接的方式:直接跳到拨号界面 NSURL *url = ...

  7. IOS 开发,调用打电话,发短信,打开网址

    IOS 开发,调用打电话,发短信,打开网址   1.调用 自带mail [[UIApplication sharedApplication] openURL:[NSURL URLWithString: ...

  8. 利用阿里大于接口发短信(Delphi版)

    阿里大于是阿里通信旗下产品,融合了三大运营商的通信能力,提供包括短信.语音.流量直充.私密专线.店铺手机号等个性化服务.每条四分五,价钱还算公道,经老农测试,响应速度非常快,基本上是秒到.官方文档提供 ...

  9. ios 调用系统发短信以及打电话功能

    先介绍一种最简单的方法: 调用打电话功能 [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://100 ...

随机推荐

  1. Jenkins install

    Linux CentOS 7.1 x64 Java 1.8 x64 apache-maven-3.3.9 Installation sudo wget -O /etc/yum.repos.d/jenk ...

  2. 『cs231n』作业3问题4选讲_图像梯度应用强化

    [注],本节(上节也是)的model是一个已经训练完成的CNN分类网络. 随机数图片向前传播后对目标类优化,反向优化图片本体 def create_class_visualization(target ...

  3. 牛客练习赛23-A/B/C/D/F

    https://www.nowcoder.com/acm/contest/156#question 链接:https://www.nowcoder.com/acm/contest/156/A来源:牛客 ...

  4. JavaScript学习总结(三)——逻辑And运算符详解

    在JavaScript中,逻辑 AND 运算符用双和号(&&)表示 1 var bTrue = true; 2 var bFalse = false; 3 var bResult = ...

  5. PHP:php中的双引号和单引号的区别

    双引号: $a="369"; $b="$a"; echo $b;//输出:369 单引号: $a="369"; $b='$a'; echo ...

  6. Python 数据类型--字典类型

    字典 dict 字典是Python的另一种有序的可变数据结构,且可存储任意类型对象. 字典是一种键值对的数据容器,每个键值(key:value)对用冒号(:)分割,每个对之间用逗号(,)分割,整个字典 ...

  7. Python sqlalchemy使用

    import sqlalchemy from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declar ...

  8. Java——使用File类递归遍历指定路劲下的所有文件

    body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...

  9. L1-052 2018我们要赢

    2018年天梯赛的注册邀请码是“2018wmyy”,意思就是“2018我们要赢”.本题就请你用汉语拼音输出这句话. 输入格式: 本题没有输入. 输出格式: 在第一行中输出:“2018”:第二行中输出: ...

  10. 玩转X-CTR100 l STM32F4 l SD卡FatFs文件系统

    我造轮子,你造车,创客一起造起来!塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] X-CTR100控制器具有SD卡接口,本教程使用免费 ...