2016-09-21 6 views
-2

Ich stelle einen Web-Service. Ich habe versucht, eine URL aber seinen Wurffehler zu schreiben. Ich komme nicht dahin, wo ich falsch liege. Ich möchte diese Variablenwerte in URL zu übergeben und in Abhängigkeit von diesem möchte ich die Web-Service diesewie den Wert in URL mit PHP

<?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

könnten Sie den Fehler –

+0

Syntaxfehler zu veröffentlichen, unerwartete T_CONSTANT_ENCAPSED_STRING – user5397448

+1

Nicht bestimmungsgemäßer Zitate Problem. Versuchen Sie dies, $ url = 'http://www.aaa.com/ajaxv2/getCompareResults.html? interesseRateType = '. $ _ POST ["interestRateType"].' & Besetzung = '. $ _ POST ["besetzung"]. & OfferingTypeId ='. $ _ POST ["offeringID"]. '& city ='. $ _ POST ["Stadt"]. '& LoanAmt ='. $ _ POST ["DarlehenAmt"]. '& Age ='. $ _ POST ["Alter"]; – user3040610

Antwort

0

Kopie nennen, weil es einige ' und . Fehler ist

$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

danke es funktionierte – user5397448

+0

Das ist großartig .. !! – Noman

1

Try Code unten. Sie Syntaxfehler haben vor &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

danke es hat funktioniert – user5397448