# -*- coding:utf-8 -*-
__author__ = 'xojisi'

import requests
import json

class YunPian(object):

    def __init__(self, api_key):
        self.api_key = api_key
        self.single_send_url = "https://sms.yunpian.com/v2/sms/single_send.json"

    def send_sms(self, code, mobile):
        parmas = {
            "apikey": self.api_key,
            "mobile": mobile,
            "text" : "【DHAC生鲜】验证码是{code}。如非本人操作，请忽略本短信.".format(code=code),
        }

        response = requests.post(self.single_send_url, data=parmas)
        re_dict = json.loads(response.text)
        return re_dict



# if __name__ == "__main__":
#     yunpian = YunPian('d8a8756690c0c322e09820abc5476e93')
#     yunpian.send_sms('2017',"18665245212")

