提问者:小点点

整合短信API,实现Woocommerce新订单


我试图将SMS API与woo商务整合为每一个新订单,但我不确定我做错了什么。我的任务是发送短信给客户,当他们下订单与支付网关C. O. D(货到付款).下面是我使用的代码。谁能告诉我我做错了什么?

add_action('woocommerce_thankyou', 'custom_process_order', 10, 1);
function custom_process_order($order_id) {

$order = new WC_Order( $order_id );
$customer_id = $order->user_id; 

$billing_phone = get_user_meta( $customer_id, 'billing_phone', true );

$data="userid=[userid]&pwd=[password]&msg=[msg]&mobileno=".$billing_phone; 

$jsonurl = curl_init('http://b2bsms.telecard.com.pk/SMSPortal/Customer/ProcessSMS.aspx');

$json = curl($jsonurl);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($json);
echo $result; 
curl_close($json);

return $order_id; 
}

错误消息是

PHP Fatal error: Call to undefined function curl() 

共1个答案

匿名用户

php中没有函数curl,对curl\u exec的调用运行http调用。您可以删除行$json=curl($jsonurl)$json$ch的任何地方使用句柄$jsonurl

$jsonurl = curl_init('http://b2bsms.telecard.com.pk/SMSPortal/Customer/ProcessSMS.aspx');
curl_setopt($jsonurl, CURLOPT_POST, true);
curl_setopt($jsonurl, CURLOPT_POSTFIELDS, $data);
curl_setopt($jsonurl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($jsonurl);
echo $result;