我正在尝试将数据发送到2个不同的网址,并且在该网址上我确实创建了邮件功能以供检查是工作但不工作我的代码是 url数组是: -
$fields = array("product" => 'post1',"orderid" => 'roder1');
$url = array( 'http://test.com/core/curl-excute.php', 'http://test2.in/external-curl.php' );
$fields_string ='';//http_build_query($_POST);
foreach($fields as $key => $value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
foreach( $url as $value ) {
if( !empty( $value ) ) {
$handle = curl_init();
curl_setopt($handle,CURLOPT_URL, $value);
curl_setopt($handle, CURLOPT_POST, 1);
curl_setopt($handle, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($handle, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($handle);
curl_close ($handle);
}
}