Open andrewdbate opened 2 years ago
Here is some more detail and a fix.
The README currently has the following code example to send a message:
// Send a new message request example
sendMessageResponse, _, err := client.TextMagicApi.SendMessage(auth, tm.SendMessageInputObject{
Text: "I love TextMagic!",
Phones: "+19998887766",
}, &tm.SendMessageOpts{})
if err != nil {
log.Fatal(err)
} else {
fmt.Println(sendMessageResponse.Id)
}
Compiling this will give the error reported above. Referring to the documentation for this function here, the third argument is not required.
Hence the code example should be corrected to reads as follow:
// Send a new message request example
sendMessageResponse, _, err := client.TextMagicApi.SendMessage(auth, tm.SendMessageInputObject{
Text: "I love TextMagic!",
Phones: "+19998887766",
})
if err != nil {
log.Fatal(err)
} else {
fmt.Println(sendMessageResponse.Id)
}
I have tested this and it works.
Another suggestion is to additionally change the line that reads
Phones: "+19998887766",
to
Phones: "+99900000",
This is because +19998887766
is not a test number and attempting to send an SMS message to this number will either charge your account (whether the message is delivered or not) or, if you do not have a dedicated US number, the message will show as rejected on the History page in your account. Using +99900000
appears to be a TextMagic test number because on the History page in my account the SMS message shows as delivered to the "TextMagic" destination country.
The v1 API docs here document the test numbers as follows:
It is possible to test all API functions without spending any SMS Credits. You just need to send SMS to the fake mobile numbers that begin with a 999 prefix. For example, 99912345678, 99987654321, and so on.
However, I cannot find the documentation of test numbers for the v2 API, but numbers beginning with a 999 prefix still seem to work as test numbers.
I am attempting to use this TextMagic Go API, but I am unable to compile the example in the README.
When I attempt to compile the usage example in the README I get the following compile errors:
I just copied the contents of the usage example to
test.go
, making sure to use the import that works with Go modules (on line 8), then rango mod init mymodule
and thengo build
and this gave the above error.Perhaps the example is out-of-date? Many thanks.