注:

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. 安装 tensorflow 时遇到 OSError: [Errno 1] Operation not permitted 的解决办法

    Installing collected packages: numpy, scipy, six, pyyaml, Keras, opencv-python, h5py, html5lib, blea ...

  2. Tree CodeForces - 1111E (树,计数,换根)

    大意: 给定树, 多组询问, 每个询问给出一个点集$S$, 给定$m, r$, 求根为$r$时, $S$的划分数, 满足 每个划分大小不超过$m$ 每个划分内不存在一个点是另一个点的祖先 设点$x$的 ...

  3. Windows下sklearn源码安装

    简介 在Windows下编译sklearn源码,主要注意二点: 编译环境的搭建 编译顺序 编译环境的搭建 如果环境没有搭建好,最常见的报错,就是"error: Unable to find ...

  4. Oracle 11g dataguard check real time apply

    2017年8月24日 16:38 环境:oracle 11.2.0.1 OEL-5.8 注:以下操作都在备库执行 总结方法: 1.FPYJ(125_7)@fpyj123> select open ...

  5. springboot activiti关闭验证自动部署

    # spring-activiti # 自动部署验证设置:true-开启(默认).false-关闭 spring.activiti.check-process-definitions=false # ...

  6. 部署docker-registry私有仓库

    部署docker-registry私有仓库 创建文件夹 sudo mkdir -p /var/docker-data/{registry,certs,auth} ​ sudo openssl req ...

  7. vue打包后图片找不到情况

    打包之前需要修改如下配置文件: 配置文件一:build>>>utils.js (修改publicPath:"../../" , 这样写是处理打包后找不到静态文件( ...

  8. bzoj3404

    题解: 博弈论 然而我直接暴力dp 代码: #include<bits/stdc++.h> using namespace std; ; int f[N],n,T; void init() ...

  9. Oracle 数据库分析

    一.数据库分析 二.表的分析 1.分析表exec dbms_stats.gather_table_stats('SFISM4','R_SN_DETAIL_T',CASCADE=>TRUE);ex ...

  10. L1-016 查验身份证

    一个合法的身份证号码由17位地区.日期编号和顺序编号加1位校验码组成.校验码的计算规则如下: 首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8, ...