简单发送飞信的代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2015-01-15 19:29:00
# @Author  : Your Name (you@example.org)
# @Link    : http://example.org
# @Version : $Id$

import os
import urllib.request 
import json

class Fetion():
	def __init__(self, UserName, PassWord):
		self.UserName = UserName
		self.PassWord = PassWord

	def sentMessage(self, ToSomeOne, Message):
		url = 'http://quanapi.sinaapp.com/fetion.php'
		values = {'u':self.UserName, 'p':self.PassWord, 'to':ToSomeOne, 'm':Message}
		data = urllib.parse.urlencode(values).encode(encoding='utf-8')
		req = urllib.request.Request(url, data)
		sentResult = urllib.request.urlopen(req)
		return sentResult.read()

def resultAnalysis(result):
	data = json.loads(result)
	return data

if __name__ == '__main__':
	fetion = Fetion('你的飞信号或手机号', '飞信密码')
	Result = fetion.sentMessage('接收方手机号', '信息').decode('utf-8')
	data = resultAnalysis(Result)
	if data['result'] == 0:
		print ('信息发送成功')
	else:
		print('信息发送出现错误, 错误原因为:%s' %data['message'])