S, 我遇到了一个问题,我想用curl将数据发送到外部系统 但是我在中间遇到了一些问题,我不知道如何将名称和值等信息发送到特定的URL。 请帮我将点击名称和值发布到网址(以下代码)
<input type=hidden name="Customer" value="v">
<input type=hidden name="cke" value="1">
<input type=hidden name="ownerid" value="2">
<input type=hidden name="overwrite" value="0">
<input type=hidden name="TriggerID" value="1951">
<input type=hidden name="PushExternal" value="1">
<input type=hidden name="rurl" value="http://www.runyourfleet.com">
<label for="City">City</label><input id="City" maxlength="40" name="City" size="20" type="text" /><br>
<label for="FirstName">FirstName</label><input id="FirstName" maxlength="40" name="FirstName" size="20" type="text" /><br>
<label for="LastName">LastName</label><input id="LastName" maxlength="40" name="LastName" size="20" type="text" /><br>
<label for="Email">Email</label><input id="Email" maxlength="40" name="Email" size="20" type="text" /><br>
<input type="submit" name="submit">
</form>
答案 0 :(得分:0)
//set POST variables
$url = 'http://url/to/post/to';
$fields = [
'Customer' => urlencode($_POST['Customer']),
'cke' => urlencode($_POST['cke']),
'FirstName' => urlencode($_POST['FirstName']),
'LastName' => urlencode($_POST['LastName']),
//etc
];
//open connection
$ch = curl_init();
foreach($_POST as $key => $value) {
$postFields .= $key.'='.$value.'&';
}
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $postFields);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
这是你要找的那种东西吗?