如何将curl数据检索到php中

时间:2015-11-24 12:22:53

标签: php curl yii

您好我正在尝试从yii文件获取curl数据到php但无法获取任何数据和restfulapi客户端显示每次“响应不包含任何数据”。 我想从我的yii文件中检索数据到php文件

这是我的yii代码

public function actionMakeWebPaytmPayment()
{
    $this->checkAuth();
    if (!isset($this->requestData->booking_id) || 
        !isset($this->requestData->user_id) || 
        !isset($this->requestData->invoice_price) || 
                    !isset($this->requestData->user_mobile) || 
                    !isset($this->requestData->user_mail) || 
        !trim($this->requestData->booking_id) ||
        !trim($this->requestData->user_id) ||  
        !trim($this->requestData->invoice_price) || 
                    !trim($this->requestData->user_mobile) ||
                    !trim($this->requestData->user_mail)){
            $this->sendErrorResponse(''
                , Constants::API_INVALID_RECHARGE_CREDIT_PAYLOAD_CODE
                , Constants::API_INVALID_RECHARGE_CREDIT_PAYLOAD_MESSAGE);
    }

       else
       {
          $paytmUrl='http://tooler.in/PaytmKit/pgRedirect.php';
          $data = json_encode(array("booking_id" => $this->requestData->booking_id ,'user_id' => $this->requestData->user_id, 'invoice_price' => $this->requestData->invoice_price,'user_mobile'=> $this->requestData->user_mobile,'user_mail'=> $this->requestData->user_mail));

          try {
        $output = Yii::app()->curl->post($paytmUrl, $data);
        $data = json_decode($output);
                    echo $data;
                    exit;
    }catch(Exception $ex){
                echo $ex;
            }
       }     
}

这里是我正在尝试检索数据的服务器中的php文件

    <?php
header('Content-Type: application/json');
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");

// following files need to be included
require_once("./lib/config_paytm.php");
require_once("./lib/encdec_paytm.php");
echo 'test';
$inputJSON = file_get_contents('php://input');
$input= var_dump(json_decode( $inputJSON, TRUE )); 
echo $input;
print_r($input);
exit();
$decoded = var_dump(json_decode($data, true));
print_r($decoded);
exit();
?>

没有echo或print命令正常工作我得到的是“响应不包含任何数据”。 任何帮助,请

0 个答案:

没有答案