gpt4 book ai didi

json - 向从数据库中获取的电话号码发送短信。代码不工作

转载 作者:数据小太阳 更新时间:2023-10-29 03:34:03 24 4
gpt4 key购买 nike

<分区>

在尝试发送短信代码时它不起作用,但是当我将 url 放入浏览器时状态为成功。当我将它与我的应用程序集成时,它无法正常工作,我正在使用 postgresql 访问详细信息。

package controllers

import (
"io/ioutil"
"log"
"net/http"

"github.com/go-gorp/gorp"
_ "github.com/go-sql-driver/mysql"
//"github.com/streetcom/app/log"
)

var (
Dbm *gorp.DbMap
)

func Sendsms(msg string) {
rows, err := Dbm.Query("Select mobile_number from alert WHERE name=$1 AND email=$2 AND mobile_number=$3")
defer rows.Close()
if err != nil {
log.Println(err.Error())
} else {
for rows.Next() {
var mobile_number string
err = rows.Scan(&mobile_number)
if err != nil {
log.Println(err.Error())
} else {
response, err := http.Get("https://api.textlocal.in/send/?apikey=redacted&sender=TXTLCL&numbers=" + mobile_number + "&message=" + msg)
if err != nil {
log.Println(err)

} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Println(err)
} else {
log.Printf("%s\n", string(contents))
}

}
}

}

}

}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com