在使用/op接口之前,先阅读接口API文档,
点击查看/op的API接口文档
如下图所示:
交易纪录数据结构为:token_x op(sms) token_y opval(phone and code) extra_data ;(非转帐推荐使用assert、config、notice等指令)
一般情况下,除非是send消息,令token_x=coin_0000000000000000(即token_root)
令token_y=coin_6dgscloudmail001(我们使用上面fork接口API创建的token-id)
发送邮件须使用mail指令,并且令opval={"mail_list":"251499600@qq.com","title":"【6DGS云】测试云邮件发送","content":"测试邮件的邮件内容
粗体字","order_number":"your-order-no","version":1}(其中mail_list参数为邮件列表--可多个邮箱群发--以英文分号“;”隔开,title为邮件标题,content为邮件内容,version暂时只能为1,order_number为订单号非必填)
因为在浏览器里直接使用该参数,所以我们进行urlencode转码:
转码工具
转码得到opval:%7b%22mail_list%22%3a%22251499600%40qq.com%22%2c%22title%22%3a%22%e3%80%906DGS%e4%ba%91%e3%80%91%e6%b5%8b%e8%af%95%e4%ba%91%e9%82%ae%e4%bb%b6%e5%8f%91%e9%80%81%22%2c%22content%22%3a%22%e6%b5%8b%e8%af%95%e9%82%ae%e4%bb%b6%e7%9a%84%e9%82%ae%e4%bb%b6%e5%86%85%e5%ae%b9%3cbr%2f%3e%3cb%3e%e7%b2%97%e4%bd%93%e5%ad%97%3c%2fb%3e%22%2c%22order_number%22%3a%22your-order-no%22%2c%22version%22%3a1%7d
接口API的URL拼接如下:
https://c0.6dgs.opencom.cn/node.testphone.coin/op?appid=10001&secret_key=bfc51077860b2927be95c0807766ca56&token_x=coin_0000000000000000&token_y=coin_6dgscloudmail001&opcode=mail&opval=%7b%22mail_list%22%3a%22251499600%40qq.com%22%2c%22title%22%3a%22%e3%80%906DGS%e4%ba%91%e3%80%91%e6%b5%8b%e8%af%95%e4%ba%91%e9%82%ae%e4%bb%b6%e5%8f%91%e9%80%81%22%2c%22content%22%3a%22%e6%b5%8b%e8%af%95%e9%82%ae%e4%bb%b6%e7%9a%84%e9%82%ae%e4%bb%b6%e5%86%85%e5%ae%b9%3cbr%2f%3e%3cb%3e%e7%b2%97%e4%bd%93%e5%ad%97%3c%2fb%3e%22%2c%22order_number%22%3a%22your-order-no%22%2c%22version%22%3a1%7d&extra_data=mail-helloworld
得到的返回结果如下:
{"ret":true,"msg":"success","txid":"txid_2whvKkw7GNYi8NG4","token_x":"coin_0000000000000000","token_y":"coin_6dgscloudmail001","x_state":{"token_state_p":"[]","token_state_val":"20","token_height":29,"pre_txid":"txid_21EfrwpDyD5MfHVq","public_key":"yizNoHddKNvchoikGRdrTaqeDJptUh9XvpnRiDfb85vz","token":"coin_0000000000000000"},"y_state":{"token_state_p":"[\"coin_0000000000000000\"]","token_state_val":"0","token_height":1,"public_key":"waW85UyHRudskDzJXdB1vc9KQsZnWZg7BvhwZvtRgt88","token":"coin_6dgscloudmail001"},"x6dgs_cloud_func_ret":{"ret":false,"msg":"send system mail-fee failed"}}
ret=true代表op接口调用和写入数据成功,这里判断短信是否发送成功是通过x6dgs_cloud_func_ret的回参数判断:
如这里所示:"x6dgs_cloud_func_ret":{"ret":false,"msg":"send system mail-fee failed"},意思是系统扣费失败,先充值。
充值帐户余额后,再次点击该URL得到下述结果:
{"ret":true,"msg":"success","txid":"txid_32MwxPRnKD1Hf44J","token_x":"coin_0000000000000000","token_y":"coin_6dgscloudmail001","x_state":{"token_state_p":"[]","token_state_val":"20","token_height":33,"pre_txid":"txid_21EfrwpDyD5MfHVq","public_key":"yizNoHddKNvchoikGRdrTaqeDJptUh9XvpnRiDfb85vz","token":"coin_0000000000000000"},"y_state":{"token_state_p":"[\"coin_0000000000000000\"]","token_state_val":"0","token_height":2,"public_key":"waW85UyHRudskDzJXdB1vc9KQsZnWZg7BvhwZvtRgt88","token":"coin_6dgscloudmail001"},"x6dgs_cloud_func_ret":{"ret":true,"msg":"success"}}
可以看到,"x6dgs_cloud_func_ret":{"ret":true,"msg":"success"}代表已经发送邮件成功。
通过6DGS云控制台的【余额管理】管理,可以看到发送邮件的扣费纪录:
可通过G节点控制台浏览发送纪录,如下图所示:
这里,因为是op操作(opcode=mail),也可通过/chain/opcode可以查询到op接口的每一条邮件指令的发送纪录点击查看/chain接口文档