我想让两个文件相互交谈。 'output_file.php'将数据从域'a'发送到位于域'b'的输入文件。 输出文件中的数据稍后将通过api发送至crm。PHP发送和接收数据curl或json
我被卡住了,因为我不知道我在做什么错,我应该在这些文件中更改什么?
这里是output_file.php:
<?php
//send cURL
$curl = 'https://domain_name/input.php';
$fields = array(
'name' => urlencode($_POST['name']),
'email' => urlencode($_POST['email']),
'tel' => urlencode($_POST['tel']),
);
//var_dump($fields);
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//var_dump($fields_string);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $curl);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
//var_dump($result);
curl_close($ch);*/
?>
这里是input_file.php:
// main data about the person. person_id is added later dynamically - PERSON DATA
$person = array(
'name' => 'name from output_file.php',
'email' => 'email from output_file.php',
'phone' => 'tel from output_file.php'
);
当你使用POST从output_file.php数据发送到input_file.php你将不得不使用$ _ POST在input_file.php让你的价值观。 – natheriel
谢谢nathariel,如果可能,请举个例子吗? – ludi