使用Curl和file_get_content php发送数据时出现问题
我试图通过cURL或使用Curl和file_get_content php发送数据时出现问题,php,curl,file-get-contents,Php,Curl,File Get Contents,我试图通过cURL或file\u get\u contents发布数据,问题是当我将数据从本地主机服务器发送到自己的服务器(生产服务器)时,数据发布正确,但当我尝试使用其他服务器(用于测试)时,数据没有发布 下面是我要发送数据的PHP文件: $json = array( 'Shop' =>$url, 'order_number' => $referencia, 'status' => $status, 'payment' => $t_pag
file\u get\u contents
发布数据,问题是当我将数据从本地主机服务器发送到自己的服务器(生产服务器)时,数据发布正确,但当我尝试使用其他服务器(用于测试)时,数据没有发布
下面是我要发送数据的PHP文件:
$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);
}
这是包含文件获取内容的代码
:
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode( $json ),
'header'=> "Content-Type: application/json\r\n" . "Accept: application/json\r\n"
)
);
$context = stream_context_create( $options );
$response = file_get_contents( $url_99, false, $context );
下面是接收JSON的代码:确保在php.ini配置文件中设置为1。您可以使用函数
phpinfo()查看当前的php.ini配置代码>。此变量设置是否允许PHP从远程服务器打开文件,并将阻止对远程服务器执行file\u get\u contents()
。确保在PHP.ini配置文件中设置为1。您可以使用函数phpinfo()查看当前的php.ini配置代码>。此变量设置是否允许PHP从远程服务器打开文件,并将阻止执行file\u get\u contents()
到远程服务器。我检查了该值并启用了,所以我不明白为什么不发送数据我检查了该值并启用了,所以我不明白为什么不发送数据