注:

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. Java 主要特性

    Java 有下面的一些主要特性. 面向对象 在 Java 中,所有的都是对象.正式因为 Java 基于对象模型,所以 Java 更加容易进行扩展. Java语言提供类.接口和继承等面向对象的特性,为了 ...

  2. 50 Jquery 库

    一.概念: 1.jquery 的选择器和ccs 相同 2.jquery对象, dom对象的集合,类似python中list,有自己的各种方法和属性 // [dom1,dom2,.....] 3.方便之 ...

  3. boruvka算法

    算法正确性证明: 1.最优性:最小边一定包含在生成树中. 2.合法性:一定不会构成环.如果存在环说明一个点的最小连边有两个,显然矛盾. 算法时间复杂度证明: 每执行一次算法,所有联通块的大小都至少为2 ...

  4. 33. 81. Search in Rotated Sorted Array *HARD*

    Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...

  5. OC MRC之循环引用问题(代码分析)

    // // main.m // 07-循环引用 // // Created by apple on 13-8-9. // Copyright (c) 2013年 itcast. All rights ...

  6. Windows系统配置Python环境,python2和python3共存

      Windows系统配置python2和python3共存   1.下载python: https://www.python.org/downloads/ 注:选择需要的版本(python2 or ...

  7. 关于std::map的第三个参数

    1.map的其中一个构造函数有第三个参数,可以直接定义map的key值得排序规则, 默认为std::less,即按“<”运算符进行排序 map<string, int> mapWor ...

  8. 070——VUE中vuex之使用getters计算每一件购物车中商品的总价

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. hadoop redis install (4)

    reference: http://dblab.xmu.edu.cn/blog/131/    https://github.com/dmajkic/redis   https://blog.csdn ...

  10. learning uboot distro design in am335x-evm board

    reference: uboot_dir/doc/README.distro Linux distributions are faced with supporting a variety of bo ...