标签:pes ret pre inet_addr port 9.1 ring ati get
#include <arpa/inet.h>#define SA struct sockaddr
#define MAXLINE 4096
#define MAXSUB 2000
#define MAXPARAM 2048
#define LISTENQ 1024
//线上线下接口宏开关
#define ONLINE
extern int h_errno;
int sockfd;
char hostname = "123.59.105.84";
char send_sms_uri = "/msg/send";
char *query_balance_uri = "/msg/balance";
/**
/**
/
ssize_t get_balance(char un, char pw)
{
char params[MAXPARAM + 1];
char cp = params;
sprintf(cp,"un=%s&pw=%s", un, pw);
return http_post(query_balance_uri, cp);
}
/**
/
ssize_t send_sms(char un, char pw, char phone, char msg)
{
char params[MAXPARAM + 1];
char cp = params;
sprintf(cp,"un=%s&pw=%s&phone=%s&msg=%s&rd=1", un, pw, phone, msg);
return http_post(send_sms_uri, cp);
}
int main(void)
{
struct sockaddr_in servaddr;
char str[50];
//建立socket连接
sockfd = socket(AF_INET, SOCK_STREAM, 0);
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_addr.s_addr = inet_addr(hostname);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(80);
inet_pton(AF_INET, str, &servaddr.sin_addr);
connect(sockfd, (SA *) & servaddr, sizeof(servaddr));
char *un = "账号";
char *pw = "密码";
char *phone = "手机号";
//必须带签名
char *msg = "【253云通讯】您的验证码是123400";
//get_balance(un, pw);
send_sms(un, pw, phone, msg);
close(sockfd);
exit(0);
}
C++短信接口demo:创蓝253平台下的短信验证码接口、短信营销接口
标签:pes ret pre inet_addr port 9.1 ring ati get
原文地址:http://blog.51cto.com/13567544/2070324