手機(jī)號(hào)碼歸屬地查詢(xún)接口文檔 點(diǎn)擊下載
手機(jī)號(hào)碼歸屬地查詢(xún)接入指南 點(diǎn)擊訪問(wèn)
// 接口類(lèi)型:互億無(wú)線手機(jī)號(hào)歸屬地查詢(xún)接口
// 賬戶(hù)注冊(cè):https://user.ihuyi.com/register.html
// 注意事項(xiàng):
// DEMO僅作參考
//linux下的編譯:g++ ./test.cpp -o ./test
//linux下的執(zhí)行:chmod +x test &&./test
#include <arpa/inet.h>
#include
#include
#include <netinet/in.h>
#include
#include
#include
#include
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include
#include
#define SA struct sockaddr
#define MAXLINE 4096
#define MAXSUB 2000
#define MAXPARAM 2048
#define LISTENQ 1024
extern int h_errno;
int basefd;
char *hostname = "api.ihuyi.com";
char *submit_uri = "/appdev/mobile/Submit.json";
/**
* 發(fā)http post請(qǐng)求
*/
ssize_t http_post(char *page, char *poststr)
{
char sendline[MAXLINE + 1], recvline[MAXLINE + 1];
ssize_t n;
snprintf(sendline, MAXSUB,
"POST %s HTTP/1.0
"
"Host: %s
"
"Content-type: application/x-www-form-urlencoded
"
"Content-length: %zu
"
"%s", page, hostname, strlen(poststr), poststr);
write(basefd, sendline, strlen(sendline));
while ((n = read(basefd, recvline, MAXLINE)) > 0) {
recvline[n] = "