我正在尝试构建一个小型应用程序,该应用程序将传入的电话号码保存到数据库,并且具有允许管理员向数据库中的号码发送爆炸消息的UI。如果有人有这方面的经验,我会喜欢一些关于如何完成这项任务的好文档或建议。如果有可能?
答案 0 :(得分:4)
以下是我的Twilio SMS应用程序的一些摘录,可能会让您了解如何与Twilio进行互动:
static const char * sms_host = "api.twilio.com";
static const char * sms_user = "AC(redacted)";
static const char * sms_pass = "(redacted)";
static const char * sms_from = "15155551212"; /* our purchased # */
static char * twilioSendTextUrl (
void
) {
return strBuild(NULL,
"https://%s:%s@%s/2010-04-01/Accounts/%s/SMS/Messages",
sms_user, sms_pass, sms_host, sms_user);
}
static char * twilioSendTextRequest (
const char * to,
const char * text
) {
if ((to == NULL) || (text == NULL)) return NULL;
return strBuild(NULL,
"From=+%s" "&"
"To=+%s" "&"
"Body=%s",
sms_from,
to,
cgiEncode(text)
);
}
static char * doPost (
const char * url,
const char * postdata
) {
CURL * curl = curl_easy_init();
int ces;
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata);
...
ces = curl_easy_perform(curl);
curl_easy_cleanup(curl);
...
}
ret = doPost(twilioSendTextUrl(), twilioSendTextRequest(number, message));