2016-09-21 27 views
-2

私はWebサービスを作成しています。 URLを書き込もうとしましたが、投げている間違いです。私はどこに間違っているのか分からない。私は、URLでこれらの変数の値を渡したいとこれに応じて、私はいくつかの'.エラーがPHPを使用してURLに値を投稿する方法

$url = 'http://www.aaa.com/ajaxv2/getCompareResults.html? 
     interestRateType='.$_POST["interestRateType"].'& 
     occupation='.$_POST["occupation"].'& 
     offeringTypeId='.$_POST["offeringID"].'& 
     city='.$_POST["city"].'& 
     loanAmt='.$_POST["loanAmt"].'& 
     age='.$_POST["age"]; 
+0

前に構文エラーを持っているあなたは、この問題を引用Inproperエラー –

+0

構文エラー、予期しないT_CONSTANT_ENCAPSED_STRING – user5397448

+1

を投稿することができます。試してみてください。$ url = 'http://www.aaa.com/ajaxv2/getCompareResults.html?interestRateType = '。$ _ POST ["interestRateType"]。'&occupation = '。$ _ POST ["occupation"]。&offeringTypeId ='。$ _ POST ["offeringID"] [" loanAmt "]。&age = '。$ _ POST [" age "]; && $ _ POST [" loanAmt "]。 – user3040610

答えて

0

コピーし、これをWebサービスを呼び出したいです。あなたは&occupation

$url = 'http://www.aaa.com/ajaxv2/getCompareResults.html?interestRateType='.$_POST["interestRateType"].'&occupation='.$_POST["occupation"].'&offeringTypeId='.$_POST["offeringID"].'&city='.$_POST["city"].'&loanAmt='.$_POST["loanAmt"].'&age='.$_POST["age"]; 
+0

ありがとうございました – user5397448

+0

それは素晴らしいです.. !! – Noman

1

はコードの下に試してみてくださいがありますので

<?php 
if($_POST["occupation"] == '1'){ 
    $occupation = 'Salaried'; 
} 
else{ 
    $occupation = 'Self+Employed'; 
} 

$url = 'http://www.aaa.com/ajaxv2/getCompareResults.html?interestRateType='.$_POST["interestRateType"]'.&occupation='.$_POST["occupation"].'&offeringTypeId='.$_POST["offeringID"].'&city='.$_POST["city"].'&loanAmt='.$_POST["loanAmt"].'&age='.$_POST["age"]; 
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); 

?> 
+0

ありがとうございましたIt Worked – user5397448

関連する問題