与我合作的第三方提供了一个示例html表单和PHP页面。
我提到了一个我想要响应的URL。 (http://localhost/myresponse.php)
当我将表单提交到example.com/thirdpartypage.php
时,我会转发到(http://localhost/myresponse.php?result=1&result2=someothervalue&result=somevalue)
。
我的问题是, 我尝试通过CURL开发相同的内容。我通过CURL POST将数据发布到URL。
但是如何才能在(http://localhost/myresponse.php?result1=1&result2=someothervalue&result3=somevalue)
CURL代码
curl_setopt ($ch, CURLOPT_URL, self::AUTHENTICATION_URL);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$status = curl_getinfo($ch);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2);
$return_data = curl_exec($ch);
curl_getinfo($ch)
Array ( [url] => https://....../thirdpartyurl.php
[content_type] => [http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => 0
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] => [primary_ip] => [certinfo] => Array ( )
[primary_port] => 0
[local_ip] => [local_port] => 0
)
答案 0 :(得分:0)
您可以尝试parse_str()和parse_url()
$url = parse_url('http://localhost/myresponse.php?result=1&result2=someothervalue&result=somevalue', PHP_URL_QUERY);
parse_str($url);
echo $result; //somevalue
echo $result2; //someothervalue