Link to home
Start Free TrialLog in
Avatar of Hamdan Shafiq
Hamdan ShafiqFlag for Pakistan

asked on

any one can help me for error?

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

Failed to connect to 10.2.217.48 port 443: Connection timed out
Avatar of Suvendu Shekhar Giri
Suvendu Shekhar Giri
Flag of India image

Please share the string you are trying JSON Parse.
Avatar of Hamdan Shafiq

ASKER

thank for replay
sadad.php
Avatar of Ryan Chong
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
the error seems come from your JSON data not from the php code.

it seems that error came from the very first line of your JSON data, post it here when necessary

or use some online JSON verifier for the checkings.

https://jsonformatter.curiousconcept.com/
https://jsonlint.com/
file attached here
soap.php
<?php
$olpIdAlias='RBUAT190';
$merchantID='1039';
$refNum=rand(1, 15).rand();
$amount='200';

$xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://olp.bank.com/sappay/service/olppaymentmanager/req">
   <soapenv:Header/>
   <soapenv:Body>
      <req:initiatePaymentDetailsReq>
         <olpIdAlias>'.$olpIdAlias.'</olpIdAlias>
         <merchantId>'.$merchantID.'</merchantId>
         <merchantRefNum>'.$refNum.'</merchantRefNum>
         <paymentAmount>'.$amount.'</paymentAmount>
         <paymentCurrency>SAR</paymentCurrency>
         <dynamicMerchantLandingURL></dynamicMerchantLandingURL>
         <dynamicMerchantFailureURL></dynamicMerchantFailureURL>
      </req:initiatePaymentDetailsReq>
   </soapenv:Body>
</soapenv:Envelope>';
try{
$url = "https://b2b.rb.com/soap?service=RB_OLP_INITIATE_PAYMENT";
 $certFile =  dirname(__FILE__)."/key.pem";
  $certPass ='b2b123';
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($ch, CURLOPT_SSLCERT, $certFile);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $certPass);
$headers = array();
array_push($headers, "Content-Type: text/xml; charset=utf-8");
array_push($headers, "SOAPAction: sii:RB_OLP_INITIATE_PAYMENT");
array_push($headers, "Host:b22.rb.com");

if($xml != null) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    array_push($headers, "Content-Length: " . strlen($xml));
}

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
      print_r($response);
      exit;
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
     print_r($response);
}  catch (Exception $e){
echo $e->getMessage();
   }


?>
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.