注:

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. android--------微信 Tinker 热修复 (一)

    什么是热修复 热修复补丁(hotfix),又称为patch,指能够修复软件漏洞的一些代码,是一种快速.低成本修复产品软件版本缺陷的方式. 热修复有多种,如:Tinker ,QZone,Andfix, ...

  2. Lucky Array CodeForces - 121E (线段树,好题)

    题目链接 题目大意: 定义只含数字$4,7$的数字为幸运数, 给定序列, 区间加正数, 区间询问多少个幸运数 题解: 对于每一个数, 求出它和第一个比它大的幸运数之差, 则问题转化为区间加,查询$0$ ...

  3. Report CodeForces - 631C (栈)

    题目链接 题目大意:给定序列, 给定若干操作, 每次操作将$[1,r]$元素升序或降序排列, 求操作完序列 首先可以发现对最后结果有影响的序列$r$一定非增, 并且是升序降序交替的 可以用单调栈维护这 ...

  4. nyoj311(完全背包变形)

    完全背包 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 直接说题意,完全背包定义有N种物品和一个容量为V的背包,每种物品都有无限件可用.第i种物品的体积是c,价值是 ...

  5. MyBatis:2

    转载:http://www.cnblogs.com/xrq730/p/5256221.html 前言 前一篇文章,讲了MyBatis入门,讲到了MyBatis有两个基本的配置文件,一个用来配置环境信息 ...

  6. ES批量索引写入时的ID自动生成算法

    对bulk request的处理流程: 1.遍历所有的request,对其做一些加工,主要包括:获取routing(如果mapping里有的话).指定的timestamp(如果没有带timestamp ...

  7. 使用iview-project 打包build报错,ERROR in xxxxx.cheunk.js from UglifyJs

    一.iview-project  为iview官方推荐工程,一个基于iview的vue脚手架 github网址:https://github.com/iview/iview-project 废话不多说 ...

  8. Idea破解办法+idea免费生成注册码+jsp属性选择器+注解什么的都报错

    Idea破解办法: http://blog.csdn.net/bitcarmanlee/article/details/54951589 idea免费生成注册码: http://idea.iteblo ...

  9. 关于这个 SDK.InvalidRegionId : Can not find endpoint to access

    String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)       TM 调试了半天,一直报错.原来是因为我改了上面的 Dysm ...

  10. Android SharedPreferences一般的读写 的用法。

    Android SharedPreferences一般用于轻量级的数据存储,比如用户名和密码等. package com.lixu.testsharepreferences; import andro ...