【问题标题】:Intergrating SMS API for new order in Woocommerce在 Woocommerce 中为新订单集成 SMS API
【发布时间】:2018-10-29 16:16:47
【问题描述】:

我正在尝试为每个新订单将 SMS API 与 woo-commerce 集成,但我不确定我在哪里做错了。我的任务是在客户使用支付网关货到付款(货到付款)下订单时向他们发送短信。下面是我正在使用的代码。谁能告诉我我做错了什么?

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() 

【问题讨论】:

  • 欢迎来到 Stack Overflow!您得到什么错误消息、堆栈跟踪或意外结果?
  • 我收到此错误消息 PHP 致命错误:调用未定义函数 curl()

标签: php wordpress woocommerce


【解决方案1】:

php中没有函数curl,调用curl_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;

【讨论】:

    猜你喜欢
    • 2018-02-24
    • 1970-01-01
    • 2015-03-12
    • 2017-07-16
    • 2018-08-09
    • 2020-04-02
    • 1970-01-01
    • 2022-01-20
    • 2020-04-13
    相关资源
    最近更新 更多