Commit 5eeb914f by usual2970

拨打电话API

parent df5327e6
util util
service/service
...@@ -22,7 +22,9 @@ type Client struct { ...@@ -22,7 +22,9 @@ type Client struct {
type Resp struct { type Resp struct {
Code,Description,Sessionid string Code string `json:"code"`
Description string `json:"description"`
Sessionid string `json:"sessionid"`
} }
func (clt *Client) AppKey() string { func (clt *Client) AppKey() string {
...@@ -93,7 +95,6 @@ func (clt *Client) Post(url string,params interface{}) (resp Resp,err error){ ...@@ -93,7 +95,6 @@ func (clt *Client) Post(url string,params interface{}) (resp Resp,err error){
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(resp)
return return
} }
......
package controllers
import (
"github.com/astaxie/beego"
"github.com/usual2970/util/tel"
"github.com/usual2970/util/service/models"
)
type TelController struct {
beego.Controller
}
func (c *TelController) Dial() {
rs:=&models.Result{"0","success",nil}
for{
from:=c.GetString("from")
if from==""{
rs.ErrNo="1"
rs.Msg="请提交主叫号码"
break
}
to:=c.GetString("to")
if to==""{
rs.ErrNo="2"
rs.Msg="请提交被叫号码"
break
}
telObj:=tel.NewTel(from,to)
resp,err:=telObj.Dial()
if err!=nil{
rs.ErrNo="2"
rs.Msg="拨打失败"
break;
}
rs.Data=resp
break
}
c.Data["json"] = rs
c.ServeJSON()
}
package models
type Result struct{
ErrNo string `json:"errNo"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
\ No newline at end of file
...@@ -7,4 +7,5 @@ import ( ...@@ -7,4 +7,5 @@ import (
func init() { func init() {
beego.Router("/", &controllers.MainController{}) beego.Router("/", &controllers.MainController{})
beego.AutoRouter(&controllers.TelController{})
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment