Tuesday, May 24, 2016

Cross Platform PHP Requrest

my $xml = <<"GENERATE_XML";

  BE
  TestStudent
  350000

GENERATE_XML

$xmlReq = array (
  'http' => array(
  'method' =>"POST",
         'header' => "Content-Type: application/xml\r\nAccept: application/xml",
         'timeout' => 60,
         'content' => $xml)
 );
 $ulr = 'http://studentrecords.com/getStduentData';
 $strCont = stream_context_create ($xmlReq);
        $filePoint = @fopen($url, 'rb', false, $strCont);
        if (!$filePoint){
  $filePoint = @fopen($url, 'rb', false, $strCont);
  if (!$filePoint) {
                    throw new Exception("Problem with $url, $php_errormsg");
                }
 }
 $response = @stream_get_contents($filePoint);
        $response_array = array();
 $response_array = simplexml_load_string($response);