Node的飞信发送类 - fetion-sender
发布于 11 年前 作者 XadillaX 4709 次浏览 最后一次编辑是 8 年前

这个类有个 demo 就是飞信喵。地址是 http://fetion.kacaka.ca/ 。当然这个 demo 也有提供发送API服务,详情请看 http://fetion.kacaka.ca/api/intro 或者 http://cnodejs.org/topic/525bc139d0af751c0e1065e9

该API目前只是部署在本人的动态域名树莓上,作测试玩玩用,网络并不稳定,若要用作各种正规用途的情三思。

不过如果你想自己提供飞信的类而不是调用网上别人写的API的话,那么就用这个 fetion-sender 吧。

安装很简单:

$ npm install fetion-sender

git地址是:https://github.com/XadillaX/fetion-sender

飞信的话,用于小群体(比如说小公司成员什么什么的)群发通知比较好用。但是希望大家不要滥用,不然很可能会被 中国移不动 公司察觉了这个bug然后修补了,到时候这个就不能用了。

<hr />

然后下面是 github 上的 README.md

Node Fetion Sender

This node package allows you to send fetion message via node.js.

Get it

You just need to install this module via npm:

$ npm install fetion-sender

Or download it from here and put it to your node_modules directory.

Another way is to clone this repo via git to your node_modules directory.

Usage

Simple

The easiest way to send a message is just shown below:

var from = "152********";
var password = "********";
var to = "152********";
var msg = "Hello world!";
var fetion = require("fetion-sender");
fetion.send(from, password, to, msg, function(status, msg) {
    if(!status) {
        console.log(msg);
    } else {
        console.log("Sent successfully!");
    }
});

Make sure that the receiver is your fetion friend.

If you sent successfully, the status in callback function will be true and msg will be an empty string. Otherwise, status is false and msg contains the error message.

Extra

If you want control the process, you will use the protocol helper.

Protocol Helper is a class of fetion sender. You can get a new protocol helper object by calling:

var helper = require("fetion-sender").createSender();

There’re several functions in that object.

Tip: The callback shown below are all in format of

function callback(status, msg);

  • status stands for the status of the function you’re called. true means succeed and false means failed.
  • msg stands for the result message. If status is true, this msg will be empty or some useful result such as user ID and so on. And if status is false, this parameter will be the error message.

Login

Login function will be called like

helper.login(username, password, callback);

Before you do anything with this helper, make sure you’re logged in.

Send

This is the send function

helper.send(phonenumber, message, callback);

Send to Friend *

This function is called by send function. But you can call it also.

helper.sendToFriend(userid, message, callback);

Caution: The first parameter is not phonenumber but userid which is returned by getUserID function.

Send to Self *

If you’re sending message to yourself (sender number is the receive number), you can’t use sendToFriend function. This function is also called by send function.

helper.sendToSelf(message, callback);

Get CSRF Token *

A CSRF token is required while you’re sending message to your friend. I think this token is something like a session id. Get a CSRF token with a friend means you’ve set up a session with him/her.

This function is called by sendToFriend.

helper.getCsrfToken(userid, callback);

Get User ID *

If you want use sendToFriend function, you must have the user ID of your friend. This function is to get the user ID with phone number.

helper.getUserID(phonenumber, callback);
5 回复

我发现乃好像一直在发各种好东西ლ(╹◡╹ლ)

-. - 这为什么算是好东西?东西很简单只不过没人造轮子或者说造了轮子没发上来而已。

楼主太萌了。。。。

@XadillaX 没发上来谁知道?总之是好东西就行啦喵

@phoenixlzx -. - 总觉得这些小众化的东西除了我自己会用用还有谁会去用。

回到顶部