-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
98 lines (71 loc) · 1.98 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
## libfxnsms: a C library for Sending SMS through Fetion(用于发短信的C库)
### 功能
+ 使用libfxnsms提供的接口,给指定手机号/飞信号发送短信
+ 可以选择发送到飞信或直接到手机
+ UTF-8编码
+ 简单易用
### API(UTF-8编码)
/*
当fxn_send返回非0,该变量记录错误信息
*/
char *fxn_error;
/*
mobile: 你的手机号
password: 你的飞信密码
to: 接收者的手机号或飞信号
sms: 要发送的短信内容
tocell: 0表示如飞信在线发送到飞信;1表示强制发送到手机
verbose: 0不输出细节;1输出细节方便调试
*/
int fxn_send(const char *mobile,
const char *password,
const char *to,
const char *sms,
const int tocell,
const int verbose);
### 下载使用
+ 下载地址:<http://code.google.com/p/libfxnsms/>
+ 安装:
tar xzvf libfxnsms-0.1.tar.gz
cd libfxnsms
sudo make install
卸载:
cd libfxnsms
sudo make clean
+ 示例代码:
//注意:代码需要保存为UTF-8编码
#include "fxn_sms.h"
#include <stdio.h>
int main(int argc, char *argv[]) {
//发送短信
if (fxn_send("13800138000", "password", "13500135000", "测试短信,test sms", 1, 1)) {
printf("success\n");
} else {
printf("%s\n", fxn_error);
}
return 0;
}
+ 编译和运行:
//使用静态库
gcc -o test test.c -lfxnsms -static
./test
//使用动态库
gcc -o test test.c -lfxnsms
./test
### 命令行工具:
下载包中的`example/cli.c`为使用libfxnsms库实现的命令行下发送短信的小工具,编译:
gcc -o cli cli.c -lfxnsms
使用cli从命令行发短信:
./cli -h
Sending SMS to your Fetion friends written by Min (http://54min.com)
-m your mobile number (required)
-p your Fetion password (required)
-t mobile number or Fetion Id of your friend (required)
-s sms to send (required)
-c in default the sms is sent to Fetion,
if set, sms will be sent to cell phone directly
-v if set, show detail
-h print this help and exit
发送短信
./cli -m 13800138000 -p password -t 13500135000 -s "the sms to send" -cv
更多实例下载包中的`example`文件。