首頁 > php教程 > php手册 > php飞信接口实例应用代码

php飞信接口实例应用代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-05-25 16:38:52
原創
1124 人瀏覽過

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

<?php

header("content-type: text/html; charset=utf-8");

error_reporting(0);

include "../libs/fetion.class.php";

$demo = $_get[demo];

$help = &#39;帮助:如果需要群发多号用英文逗号(,)分隔(159..,159..),有更多建议请联系 qq:85431993<br>e-mail:threesky@gmail.com&#39;;

$api = "本站接口:<br>http://api.heqee.com/fetion/?username=飞信手机号码&passowrd=飞信手机密码&to=接收人号码&message=短信内容<br>或者<br>http://api.heqee.com/fetion/?u=飞信手机号码&p=飞信手机密码&t=接收人号码&m=短信内容";

if ($demo != "") {

    if (!in_array($demo, array(

        "send",

        "code",

        "help",

        "api"

    ))) {

        error("参数错误!");

    }

    switch ($demo) {

        case "code":

            exit(highlight_file("demo.php", true));

            break;

        case "help":

            exit($help);

            break;

        case "api":

            exit($api);

            break;

    }

}

function getval($key) {

    if (!isset($_post[$key]) || $_post[$key] == null || $_post[$key] == &#39;&#39;) {

        return ($_get[$key] != &#39;&#39; && isset($_get[$key])) ? trim($_get[$key]) : null;

    } else {

        return ($_post[$key] != &#39;&#39; && isset($_post[$key])) ? trim($_post[$key]) : null;

    }

}

function error($msg) {

    exit("<b>heqee info:</b> " . $msg);

}

function gbktoutf8($value) {

    return iconv("gbk", "utf-8", $value);

}

$send = array();

$send[&#39;username&#39;] = getval(&#39;username&#39;) != null ? getval(&#39;username&#39;) : getval(&#39;u&#39;);

$send[&#39;password&#39;] = getval(&#39;password&#39;) != null ? getval(&#39;password&#39;) : getval(&#39;p&#39;);

$send[&#39;to&#39;] = getval(&#39;to&#39;) != null ? getval(&#39;to&#39;) : getval(&#39;t&#39;);

$send[&#39;message&#39;] = gbktoutf8(getval(&#39;message&#39;) != null ? getval(&#39;message&#39;) : getval(&#39;m&#39;));

$send[&#39;message_len&#39;] = strlen($send[&#39;message&#39;]);

switch ($send) {

    case $send[&#39;username&#39;] == null:

        error(&#39;请输入登陆手机的号码.&#39;);

        break;

    case $send[&#39;password&#39;] == null:

        error(&#39;请输入登陆手机的密码.&#39;);

        break;

    case $send[&#39;to&#39;] == null:

        error(&#39;请输入接收手机的号码.&#39;);

        break;

    case $send[&#39;message&#39;] == null:

        error(&#39;请输入短信内容.&#39;);

        break;

    case $send[&#39;message_len&#39;] > 360:

        error(&#39;消息内容不能超过180个字符.&#39;);

        break;

}

$fetion = new fetion($send[&#39;username&#39;], $send[&#39;password&#39;]);

$fetion->send($send[&#39;to&#39;], $send[&#39;message&#39;]);

/*

    所需php扩展:curl, simplexml

*/

include "libs/fetion.class.php";

//设置飞信帐号密码

$username = "15900000000";

$password = "password";

//接收号码,多号码用","分隔(159..,159..)

$sendto = "15900000000,13400000000";

//消息内容

$message = "i am from heqee.com";

//开源代码phprm.com

//实例化(必须)

$fetion = new fetion($username, $password);

//发送 返回布尔

$sms = $fetion->send($sendto, $message);

if ($sms) {

    echo "ok";

}

登入後複製


永久链接:

转载随意!带上文章地址吧。

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板