|
|
@@ -10,7 +10,7 @@ route.post("/hook", async c => {
|
|
|
|
|
|
route.get("/addTester", async c => {
|
|
|
return c.html(`<form action="/rcs/addTester" method="post">
|
|
|
- <input name="number" />
|
|
|
+ <input name="number" placeholder="enter your number"/>
|
|
|
<button type="submit">add</button>
|
|
|
</form>`)
|
|
|
})
|
|
|
@@ -18,7 +18,30 @@ route.get("/addTester", async c => {
|
|
|
route.post("/addTester", async c => {
|
|
|
const form = await c.req.formData()
|
|
|
const number = form.get("number")
|
|
|
- await getAccessToken()
|
|
|
+ if (!number) {
|
|
|
+ return c.html("invalid number", 400)
|
|
|
+ }
|
|
|
+ const token = await getAccessToken()
|
|
|
+ const response = await fetch(
|
|
|
+ "https://api.dotgo.com/rcs/bot/v1/ZBtzSyi7jOThVQVA/messages",
|
|
|
+ {
|
|
|
+ method: "POST",
|
|
|
+ headers: {
|
|
|
+ Authorization: `Bearer ${token}`,
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ RCSMessage: {
|
|
|
+ textMessage: "HI"
|
|
|
+ },
|
|
|
+ messageContact: {
|
|
|
+ userContact: number
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ )
|
|
|
+ const res = await response.json()
|
|
|
+ console.log(res)
|
|
|
return c.html(`a message has been sent to ${number}`)
|
|
|
})
|
|
|
export default route
|