1
This commit is contained in:
@@ -2,6 +2,7 @@ package baidunavi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi"
|
"git.rosy.net.cn/baseapi/platformapi"
|
||||||
@@ -210,7 +211,7 @@ func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoord
|
|||||||
|
|
||||||
result, err := a.AccessAPI2("geoconv/v1/", params)
|
result, err := a.AccessAPI2("geoconv/v1/", params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = utils.Map2StructByJson(result, &outCoords, false)
|
err = utils.Map2StructByJson(result[resultKey], &outCoords, false)
|
||||||
}
|
}
|
||||||
return outCoords, err
|
return outCoords, err
|
||||||
}
|
}
|
||||||
@@ -231,13 +232,13 @@ func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err e
|
|||||||
|
|
||||||
resp, err := a.AccessAPI2(apiStr, param)
|
resp, err := a.AccessAPI2(apiStr, param)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return resp, nil
|
return resp[resultKey], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal interface{}, err error) {
|
func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal map[string]interface{}, err error) {
|
||||||
|
|
||||||
for _, v := range BaiduAKList {
|
for _, v := range BaiduAKList {
|
||||||
param.Add("ak", v)
|
param.Add("ak", v)
|
||||||
@@ -264,9 +265,12 @@ func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal interface{}, e
|
|||||||
if err1 != nil || err2 != nil {
|
if err1 != nil || err2 != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result := string(body)
|
//result := string(body)
|
||||||
|
//result := map[string]interface{}{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(body, &retVal)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result, nil
|
return retVal, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errors.New("所有百度应用额度均用完")
|
return nil, errors.New("所有百度应用额度均用完")
|
||||||
|
|||||||
@@ -18,30 +18,17 @@ func TestAPI_UpdateIMStatus(t *testing.T) {
|
|||||||
fmt.Printf("err=%v", err)
|
fmt.Printf("err=%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseMultilayerJson(t *testing.T) {
|
func TestSendMsg(t *testing.T) {
|
||||||
// //var data1 = `{"subBizType": "SEND_MESSAGE","bizType": "IM","payload": {"senderId":"20235760123","receiverIds":["105872382789","30506545123","20235760456"],"createTime":1642647893901,"groupId":"$2$10514249123$PNM","msgId": "1654907240123.PNM","contentType": "1","content":"{"text":"测试消息"}"},"platformShopId": "32267818868"}`
|
err := api.BusinessSendMsg(&BusinessSendMsgReq{
|
||||||
// var data8 = `{
|
PlatformShopId: "1157916361",
|
||||||
// "subBizType": "SEND_MESSAGE",
|
BizType: IMType,
|
||||||
// "bizType": "IM",
|
SubBizType: SubTypeDef,
|
||||||
// "payload": {
|
Payload: BusinessMsgPayload{
|
||||||
// "senderId": "102000022769889",
|
GroupId: "$2$13205337818$PNM",
|
||||||
// "receiverIds": ["102000022769889", "30507511668"],
|
ReceiverIds: []string{"301157916361", "10154538612", "321921188187760"},
|
||||||
// "createTime": 1680579669946,
|
Content: "{\"text\": \"现在是20231027 10:04:44\"}",
|
||||||
// "groupId": "$2$10996707119$PNM",
|
ContentType: "1",
|
||||||
// "msgId": "1734454964456.PNM",
|
},
|
||||||
// "contentType": 8,
|
})
|
||||||
// "content": "{\"elements\":[{\"elementContent\":\"{\\\"atAll\\\":false,\\\"defaultNick\\\":\\\"\\\",\\\"uid\\\":{\\\"appUid\\\":\\\"30507511668\\\",\\\"domain\\\":\\\"eleme\\\"}}\",\"elementType\":3},{\"elementContent\":\"{\\\"extensions\\\":{},\\\"text\\\":\\\"@商家 我选的就是退一个杯子呀\\\"}\",\"elementType\":1}]}"
|
fmt.Println(err)
|
||||||
// },
|
|
||||||
// "platformShopId": "507511668"
|
|
||||||
//}`
|
|
||||||
// //retVal1 := ParseMultilayerJson(data1)
|
|
||||||
// //fmt.Println(utils.Format4Output(retVal1, false))
|
|
||||||
// //retVal8 := ParseMultilayerJson(data8)
|
|
||||||
// //fmt.Println(utils.Format4Output(retVal8, false))
|
|
||||||
// temp := ImMessageSent{}
|
|
||||||
// err := json.Unmarshal([]byte(data8), &temp)
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println(err)
|
|
||||||
// }
|
|
||||||
// fmt.Println(temp)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user