我在 $url$_REQUEST
和$_POST
变量上打印.. 只显示一个空数组.. 我做错了什么?
function redirect_post($url, $data, $headers = null)
{
// Url Encoding Data
$encdata = array();
foreach ($data as $key => $value) {
$encdata[$key] = urlencode($value);
}
//url-ify the data for the POST
$encdata_string = http_build_query($encdata);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_POST,count($encdata));
curl_setopt($ch,CURLOPT_POSTFIELDS,$encdata_string);
//execute post
$result = curl_exec($ch);
echo $result;
die;
}