我尝试通过cURL或Controller
发布数据,问题是当我从本地主机服务器向我自己的服务器(生产服务器)发送数据时,数据发布正确,但是当我尝试使用其他服务器时(这是用于测试)数据没有发布。
这是我发送数据的PHP文件:
file_get_contents
这是包含$json = array(
'Shop' =>$url,
'order_number' => $referencia,
'status' => $status,
'payment' => $t_pago,
'shipping_method' => $carrierData,
'costo_envio' => $costo_envio,
'products' =>$products,
'total_weight' => $orderWeight,
'firstname' => $firstname,
'lastname' => $lastname,
'address1' => $address1,
'address2' => $address2,
'postcode' => $postcode,
'country' => $country,
'city' => $city,
'phone' => $phone,
'email' => $email,
'note' => $orderMessage,
);
if($params['newOrderStatus']->id == 4) {
$data = json_encode($json);
$ch = curl_init('http://api.com/prestashop/shipping.php');
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($ch);
curl_close($ch);
}
的代码:
file_get_content
以下是接收JSON的代码:code
答案 0 :(得分:0)
确保php.ini配置文件中的allow_url_fopen
设置为1。您可以使用函数phpinfo();
查看当前的php.ini配置。此变量设置是否允许PHP从远程服务器打开文件,并阻止file_get_contents()
执行到远程服务器。