【发布时间】:2014-11-28 14:58:12
【问题描述】:
我使用 Contact Form 7 表单在外业电话中捕获用户的电话号码,以向他发送 SMS 提醒,如下所示:
<p>Your phone number<br />
[text* phone] </p>
<p>[submit "Send"]</p>
在我的 Wordpress 主题的功能中,我有以下内容:
add_action( 'wpcf7_mail_sent', 'your_wpcf7_mail_sent_function' );
function your_wpcf7_mail_sent_function( $contact_form ) {
$title = $contact_form->title;
$posted_data = $contact_form->posted_data;
if ( 'smsservice' == $title ) {
$phone = $posted_data['phone'];
require_once 'http://myurl.com/smsservice/send_sms.php';
}
}
在链接 send_sms.php 中我得到了:
# Modify these values to your needs
$username = 'myusername';
$pass = 'mypassword';
$gateway_url = 'api-adress';
$utf8_message_text = "This is a test sms!";
$recipientAddressList = array['$phone']
$maxSmsPerMessage = 1;
$test = false; // true: do not send sms for real, just test interface
try {
// 1.) -- create sms client (once) ------
$smsClient = new WebSmsCom_Client($username, $pass, $gateway_url);
//$smsClient->setVerbose(true);
// 2.) -- create text message ----------------
$message = new WebSmsCom_TextMessage($recipientAddressList, $utf8_message_text);
//$message = binary_sms_sample($recipientAddressList);
// 3.) -- send message ------------------
$Response = $smsClient->send($message, $maxSmsPerMessage, $test);
但是,每次我填写表格时,它什么也没做。甚至不发送表格。但是,从 PHP 代码中我似乎找不到错误。还有人吗?
最好的问候, 赛博
【问题讨论】:
标签: php wordpress sms contact-form contact-form-7