简体   繁体   English

集成SMS API以实现Woocommerce中的新订单

[英]Intergrating SMS API for new order in Woocommerce

I am trying to integrate SMS API with woo-commerce for every new order but i am not sure where i am doing wrong. 我正在尝试为每个新订单将SMS API与woo-commerce集成在一起,但是我不确定我在哪里做错了。 My Task is to send SMS to customer when they place order with Payment Gateway COD (Cash on Delivery). 我的任务是在客户使用Payment Gateway COD(货到付款)下订单时向客户发送SMS。 Below is the code i am using. 下面是我正在使用的代码。 Can anyone tell me what i am doing wrong? 谁能告诉我我在做什么错?

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; 
}

The error message is 错误消息是

PHP Fatal error: Call to undefined function curl() 

There is no function curl in php, the call to curl_exec runs the http call. php中没有curl函数,对curl_exec的调用将运行http调用。 You can remove the line $json = curl($jsonurl); 您可以删除行$json = curl($jsonurl); in your code, and use the handle $jsonurl everywhere where you are using $json or $ch at the moment: 在您的代码中,并在当前使用$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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM