Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.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_Magento_Redirect_Microservices_Http Redirect - Fatal编程技术网

如何在PHP中使用重定向发布

如何在PHP中使用重定向发布,php,magento,redirect,microservices,http-redirect,Php,Magento,Redirect,Microservices,Http Redirect,细节流 描述 magento站点向API发送帖子 API中间件/微服务将订单保存到数据库并重定向到支付网关 支付网关响应重定向到API支付 将回调重定向到magento magento代码。发送邮件到api $uri = sprintf('%s/%s', 'http://api.tld', '/request'); $config = array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions'

细节流

描述

  • magento站点向API发送帖子
  • API中间件/微服务将订单保存到数据库并重定向到支付网关
  • 支付网关响应重定向到API支付
  • 将回调重定向到magento
  • magento代码。发送邮件到api

    $uri = sprintf('%s/%s', 'http://api.tld', '/request');
    $config = array(
        'adapter'   => 'Zend_Http_Client_Adapter_Curl',
        'curloptions' => array(CURLOPT_FOLLOWLOCATION => true),
    );
    $client = new Zend_Http_Client($uri, $config);
    $client->setMethod(Zend_Http_Client::POST);
    $client->setRawData(json_encode(['api' => $api, 'pg' => $data]));
    $response = $client->request();
    
    编写api中间件代码,并且必须重定向到支付网关

    $content = file_get_contents('php://input');
    $data = json_decode($content, true);
    $pg = $data['payment_gateway'];// require post to payment gateway
    
    $payment = 'http://paymentgateway.tld/purchase';
    $client = new Client(['base_uri' => $payment, 'allow_redirects' => true]);
    $res = $client->request('POST', null, $pg);
    
    // the problem is not redirect to $payment.
    header("Location: $payment");
    

    问题是如何在从magento站点发送帖子后重定向到API中间件中的支付网关。这实际上取决于支付网关支付网关是否正常,没有问题。只是无法重定向到页面支付网关。返回空白页