我有一个表格,我创建了一个网址来获取数据。它正在正确获取数据,但是当我点击网址时它会显示{{error“:”null“}。如何获得提交的价值?我无法显示Web服务。我正在尝试创建一个Web服务。在我尝试使用值
命中网址时提交表单http://www.apnapaisa.com/ajaxv2/getCompareResults.html?rateType=Both&occupation=Salaried&offeringTypeId=31&city=79&loanAmt=500000&q=&age=27
它给了我{“error”:“null”}错误
<?php
if($_POST["occupation"] == '1'){
$occupation = 'Salaried';
}
else{
$occupation = 'Self+Employed';
}
$url = 'http://www.apnapaisa.com/ajaxv2/getCompareResults.html?productId='.$_POST["product_id"].'&rateType=Floating&occupation='.$occupation.'&monthlyIncome='.$_POST["dincome"].'&offeringTypeId='.$_POST["offeringID"].'&city='.$_POST["city"].'&monthlyIncomeSingle='.$_POST["dincome"].'&loanAmt='.$_POST["loan"].'&q='.$_POST["q"].'&age='.$_POST["age"].'&tenure='.$_POST["tenure"];
echo $url;
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
$json = json_decode($result, true);
//print_r($json);
//echo $json['resultList']['interestRateMin'];
$json_array = $json['resultList'];
//print_r($json_array);
?>
<?php
if (is_array($value)) {
foreach ($json['resultList'] as $key=>$value) {
if($json["resultList"][$key]["interestRateMin"] == $json["resultList"][$key]["interestRateMax"]){
$interest = $json["resultList"][$key]["interestRateMin"];
}
else{
$interest = $json["resultList"][$key]["interestRateMin"].' - '.$json["resultList"][$key]["interestRateMax"];
}
echo '
<div class="bank-rates">
<ul>
<li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="'.$json["resultList"][$key]["imageUrl"].'"></span></div></li>
<li><div class="innr-spl2">'.$json["resultList"][$key]["interestRateMin"].'%'.'</div></li>
<li><div class="innr-spl2">60</div> </li>
<li class="hide"><div class="innr-spl3 view-detail1" id="'.$key.'"><i class="fa fa-chevron-circle-down" aria-hidden="true"></i>View Datails</div> </li>
<li><div class="apply-now innr-spl"><a href="#" type="button" role="button" target="_blank" class="btn-apply">Apply Now</a></div></li>
</ul>
<div style="clear:both"></div>
<div id="ban_'.$key.'">
<ul class="details" id="details1">
<li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Maximum Loan Amount : '.$json["resultList"][$key]["loanAmt"].'</li>
<li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Max Tenure (In Years) : '.$json["resultList"][$key]["tenure"].'</li>
<li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Interest Rate Type : '.$json["resultList"][$key]["rateType"].'</li>
</ul>
</div>
</div>
';
$i++;
}
}
?>
答案 0 :(得分:0)
// $postData = xxx; //add your data
foreach($_POST as $k => $v)
{
$postData .= $k . '='.$v.'&';
}
$postData = rtrim($postData, '&');
$url ="http://www.apnapaisa.com/ajaxv2/getCompareResults.html"
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, TRUE); // Includes the header in the output
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postData);
$output=curl_exec($ch);