Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重定向完成后,如何在php无脂肪框架中返回到同一步骤?_Php_Curl_Url Redirection_Fat Free Framework - Fatal编程技术网

重定向完成后,如何在php无脂肪框架中返回到同一步骤?

重定向完成后,如何在php无脂肪框架中返回到同一步骤?,php,curl,url-redirection,fat-free-framework,Php,Curl,Url Redirection,Fat Free Framework,我使用php和无脂肪框架 我有以下场景:一个客户端转到process.php页面插入金额和货币,然后单击submit并重定向到example.com的远程页面以填写更多详细信息,然后他重定向回我提供的returnurl链接。。。但我需要代码继续从相同的步骤3,以完成我的网站上的过程。 我使用header()而不是curl_exec(),因为我尝试过它不起作用 页面:process.php 步骤1: 使用要发布的数据构建api url 步骤2: 重定向到构建的链接,并在远程api上完成该过程后,它

我使用php和无脂肪框架

我有以下场景:一个客户端转到process.php页面插入金额和货币,然后单击submit并重定向到example.com的远程页面以填写更多详细信息,然后他重定向回我提供的returnurl链接。。。但我需要代码继续从相同的步骤3,以完成我的网站上的过程。 我使用header()而不是curl_exec(),因为我尝试过它不起作用

页面:process.php

步骤1: 使用要发布的数据构建api url

步骤2: 重定向到构建的链接,并在远程api上完成该过程后,它将一个数据数组返回到数据中发布的returnurl链接

步骤3: 从api返回的数据将继续从同一步骤3处理.php。。。 ***客户端应重定向回此处以继续此过程


你面临的问题是什么?在步骤3中,$result可能是空的?问题是如果我只使用cURL,就像在cURL\u exec($cURL)中一样,它返回数据,但是redirect\u url字段为空,这可能就是cURL不工作的原因。这就是为什么我使用header('Location:'.$url);但是如果我使用header(),我不知道如何在调用$this->call()…header函数和cURL函数不同的地方继续运行代码,当您在header函数中发送位置时,您正在重定向用户,无法从发送header的同一行返回并继续。我认为该header无法重定向到同一行。那么,如果重定向url为空,我如何使用cURL呢?如果我像这样使用cURL:private function call_netpay($url,$params){$cURL=cURL_init();cURL_setopt($cURL,CURLOPT_POST,true);cURL_setopt($cURL,CURLOPT_url,$url.'?)。http_build_query(($params));$info=cURL_getinfo($cURL);var_dump($info);cURL_close($cURL);return$info['url'];}
function call($url, $data){
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl,CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
if ($params) {
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
}
$info = curl_getinfo($curl);
curl_close($curl);
return $info['url'];
}
$url = "http://www.example.com/hosted"; $data= array(
"amount"=>"100",
"currency"=>"USD",
"returnurl"=>"http://www.mywebsite.com/process");
$link=$this->call($url,$data);
header('Location:'.$link);
$result=explode("&",$_SERVER['QUERY_STRING']);
$response=array();
foreach($result as $fields){
$field=explode("=",$fields);
$response[$field[0]]=urldecode($field[1]);}
switch($response['status']){
case 'success':
return 1;
break;
case 'fail:
default:
return 2;
break;}