潮水退去,才知道谁在裸泳。
远程服务器地址: 103.205.5.249
远程服务器端口号: 80
API接口: http://api.k780.com/?app=ip.local&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json
{
"success": "1",
"result": {
"ip": "102.212.134.15",
"proxy": "1",
"att": "中国,北京",
"operators": "联通"
}
}
#include "cJSON.h"
uint8_t parse_api_data(char *jsonstr)
{
cJSON *root;
cJSON *result;
char *ip;
char *loc;
char *net;
// printf("recv data: %d-%s\r\r\n", strlen((const char*)jsonstr), jsonstr); //JSON原始数据
root = cJSON_Parse((const char*)USART2_RX_BUF);
if (root != 0)
{
printf("---JSON format ok---\r\n");
result = cJSON_GetObjectItem(root, "result");
ip = cJSON_GetObjectItem(result, "ip")->valuestring; //164.123.44.15
loc = cJSON_GetObjectItem(result, "att")->valuestring; //中国,北京
net = cJSON_GetObjectItem(result, "operators")->valuestring;//联通
printf("ip:%s\r\nloc:%s\r\nnet:%s\r\n", ip, loc, net);
}
else
{
printf("JSON format error:%s\r\n", cJSON_GetErrorPtr()); //输出json格式错误信息
return 1;
}
cJSON_Delete(root);
return 0;
}
/* 返回IP地址,地区、时序、国家等信息,默认是英文的 */
http://ip-api.com/json/
/* 可选中文 */
http://ip-api.com/json/?lang=zh-CN
/* SOHU接口,非标准JSON */
http://pv.sohu.com/cityjson
/* 国内的PCOnline提供的接口,定位不准确 */
http://whois.pconline.com.cn/ipJson.jsp?json=true&ip=14.16.139.216
/* 国外geoplugin公司提供的接口,包括经纬度、时区、货币单位、对美元汇率等信息 */
http://www.geoplugin.net/json.gp
1.SylixOS,这款嵌入式RTOS值得学习!
2.芯片短缺或将结束?数据来说话。。。
3.代码调着调着就失联了,你碰到过吗?
4.图文并茂详解STM32时钟配置
5.电力物联网与嵌入式系统,关系几何?
6.RT-Thread携手北航出版社共办人工智能师资培训
免责声明:本文系网络转载,版权归原作者所有。如涉及作品版权问题,请与我们联系,我们将根据您提供的版权证明材料确认版权并支付稿酬或者删除内容。