Sending XML data using curl - php

I am trying to invoke a webservice uisng curl. I am receiving "connection timed out" error while running this script. Please assist me to resolve this issue.
Client:
<?php
#parameters
$strParams = '';
$strAPIname = 'CordecAPI';
$url = 'http://86.17.13.109:81/Webbooker';
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<SOAPENV:Envelope
xmlns:SOAPENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAPENC="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAPENV:Body>
<JobRequest xmlns="http://81.105.223.86:80/cni">
<SourceSystem>KVCARS</SourceSystem>
<SourcePassword>Ketchup96</SourcePassword>
<SourceJobID>*KV001*</SourceJobID>
<SourceAccount>CORDIC</SourceAccount>
<TargetSystem>TARGET1</TargetSystem>
<Lifetime>60</Lifetime>
<DriverNotes>Please wait at reception.</DriverNotes>
<OperatorNotes>Test job for CNI.</OperatorNotes>
<BookerName>Jane</BookerName>
<BookerPhone>01954233255</BookerPhone>
<BookerEmail>jane.test#cordic.com</BookerEmail>
<StopList>
<Stop>
<Order>1</Order>
<Passenger>Fara Arani</Passenger>
<Address>Cordic Ltd, 1 Rowles Way, Swavesey, Cambridge</Address>
<Postcode>CB24 4UG</Postcode>
<ContactPhone>01954233255</ContactPhone>
<ContactOnArrive>Ring</ContactOnArrive>
</Stop>
<Stop>
<Order>2</Order>
<Address>Heathrow Airport, Terminal 4</Address>
<Postcode>TW6 3GA</Postcode>
</Stop>
</StopList>
<AttributeList>
<Attribute>Executive</Attribute>
<Attribute>Professional</Attribute>
</AttributeList>
</JobRequest>
</SOAPENV:Body>
</SOAPENV:Envelope>';
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($xml) ));
//curl_setopt($soap_do, CURLOPT_USERPWD, $user . ":" . $password);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
$inf = curl_getinfo($soap_do);
if(!$result)
{
echo "CURL FAIL: $url TIMEOUT=10, CURL_ERRNO=$err";
echo PHP_EOL . '<pre>' . PHP_EOL;
var_dump($inf);
echo PHP_EOL . '</pre>' . PHP_EOL;
}
echo $result;
echo $err;
?>
If you have any example in soap. Please share with me, but I am more comfortable with curl methods.
Thanks !

You must set the header with SOAPAction: ""
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""'));

Hi, Solution resolved,
//curl_setopt($soap_do, CURLOPT_USERPWD, $user . ":" . $password);
I just put the user name and password information and its working now
Denil:
Your comments were also helpful, thank you very much for helping. and thanks to stackoverflow Team for this portal.
Best Regards!
Ali Raza
+92 336 5141224

Related

PHP cURL submit to WSDL SOAP environment

I've never had the opportunity to submit to a WSDL SOAP web service and am running into some issues. Im using PHP cURL to submit the form to a known back end fist, then secondly to the WSDL SOAP service. The first part is working fine, so I will skip over that. I have spent the better part of 3 days trying different solutions I've found on the web, and my own after reading SOAP documentation, with no luck.
Here is what I'm using to submit to the WSDL
<?php
//first cURL POST HERE - works fine
//second cURL POST BELOW
$FName = $_POST['FirstName'];
$Lname = $_POST['LastName'];
$Email = $_POST['Email'];
$Phone = $_POST['Phone1'];
$soapURL = "https://something.com/IBWeb/IBDemoManager/IBDemoManager.asmx?wsdl";
$soapUser = "USR";
$soapPassword = "PWD";
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$xml_post_string = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.htdocs.openecry">
<soapenv:Header/>
<soapenv:Body>
<web:demosetup soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<AccessCode xsi:type="xsd:string">G0!=#%fut40</AccessCode>
<NewUserCategoryName xsi:type="xsd:string">OFLDemo</NewUserCategoryName>
<TemplateUserName xsi:type="xsd:string">OFLUser</TemplateUserName>
<CusType xsi:type="xsd:string">Indirect</CusType>
<WLabelID xsi:type="xsd:string">276</WLabelID>
<SCodeID xsi:type="xsd:string"></SCodeID>
<SoftID xsi:type="xsd:string">1</SoftID>
<FName xsi:type="xsd:string">'.$FName.'</FName>
<LName xsi:type="xsd:string">'.$LName.'</LName>
<Email xsi:type="xsd:string">'.$Email.'</Email>
<Phone xsi:type="xsd:string">'.$Phone.'</Phone>
<Address xsi:type="xsd:string"></Address>
<City xsi:type="xsd:string"></City>
<Zip xsi:type="xsd:string"></Zip>
<State xsi:type="xsd:string"></State>
<Country xsi:type="xsd:string"></Country>
<CountryName xsi:type="xsd:string"></CountryName>
<AssetTypes xsi:type="xsd:string">Futures</AssetTypes>
<How xsi:type="xsd:string">OFL webservice</How>
<MoreEmail xsi:type="xsd:string"></MoreEmail>
<RemoteAddr xsi:type="xsd:string">'.$hostname.'</RemoteAddr>
<CampaignID xsi:type="xsd:string"></CampaignID>
</web:demosetup>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
//IS SOAPAction the same as the endpoint "$soapURL"?//
"SOAPAction: https://something.com/IBWeb/IBDemoManager/IBDemoManager.asmx?wsdl",
"Content-length: ".strlen($xml_post_string),
);
$url2 = $soapURL;
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url2 );
curl_setopt($soap_do, CURLOPT_HEADER, false);
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 100);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers);
if(curl_exec($soap_do) === false) {
$err = 'Curl error: ' . curl_error($soap_do);
curl_close($soap_do);
print $err;
} else {
$result = curl_exec($soap_do);
echo '<pre>';
print_r($result);
curl_close($soap_do);
//print 'Operation completed without any errors';
}
Here are just some comments:
Try to disable the SSL check (just for testing):
curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, 0);
You should call curl_close($ch2); as last. Example:
$output2 = curl_exec($ch2);
if(curl_errno($ch2))
echo curl_error($ch2);
} else {
echo $output2;
}
curl_close($ch2); // <--- close here
You could also try the Zend SOAP library.
If you don't like CURL try Guzzle to make an HTTP request.

"Invalid toke" and "signature invalid" errors with OAuth2 request

I was wondering if someone might be able to point out where my request is getting messed up. I am trying to connect using OAuth2 but I am getting a weird error.
I have tried playing around with some of the header options but to no avail. For some reason I think it's something simple I am getting wrong. I am just getting started with OAuth2.
It is returning:
array(5) {
["access_token"]=>
string(88) "//43773esO1jYyy4hEZ0EXjovF21uqvIQC5U4TzLf8b+LhLf/fYnw3i5bMNkFTiynTZdIvNO9mlW90QhcKLuxg=="
["token_type"]=>
string(3) "mac"
["secret"]=>
string(88) "tCAU89rpW9RGoF28EHufUuLG1GBA+CquUuPqh9svQ9Y8ofkqucpMnt+9X9pqgYgE6GBalBwKGNTerMcCDqh5lA=="
["algorithm"]=>
string(12) "hmac-sha-256"
["expires_in"]=>
int(3599)
}
E3Bgu19tbvYKEwMLv7p6rgUfKFMHgudBm4hOUMcBCOI=
string(65) "{"error":"invalid_token","error_description":"Signature Invalid"}"
Here is my script:
<?php
$identifier = "QSJMuz3wGIMBbeL6rciemeIJSZ7H5fnuQgU5urztijK6DkFCxLW0FDgqIRraTPW7PiehKM+5mi+U9S45ORGA4igJfmVlv0w0WqNGQ1Rz4v2wakbt26HyVrJg/0ybE0KQMB0qjL/jj3xwOBkPA1FmU1x612axwPY1yMEZYHB9FhfUinFEdhSTd2alSpr5YgJlZDwZ6IK6Z2JaDYOP0S2e3A==";
$decrypted_id = "dTBFdjlqVStXc1BYN2hSUE1lZVY2QWdaWWI2SjlTdG9nNnVtVUgrb04wb1dpeWhtdUZKT1FIUEZmSW1GeDNpa2xjZnpJWTU1d2FmQVIwMlhlVldTN0E9PTpxVXpHSXdYQVJldG82dGplMnU2YzZBPT0=";
$r = rand(0, 25);
$arr = explode(':', base64_decode($decrypted_id));
$p1 = $arr[1];
$p0 = $arr[0];
$res = base64_encode($p1 . ":" . $p0);
$headers = array('Authorization: Basic ' . $res);
$posts = array('unique_id', $decrypted_id . ':' . $r);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://ishin-global.aktsk.com/auth/sign_in");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($posts));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
$server_output = curl_exec ($ch);
$server_output = json_decode($server_output, true);
echo "<pre>";
var_dump($server_output);
echo "</pre>";
curl_close ($ch);
?>
<?php
$access_token = $server_output["access_token"];
$secret = $server_output["secret"];
$ts = time();
$nonce = $ts . ":" . uniqid();
$url = "https://ishin-global.aktsk.com/user";
$url_host = parse_url($url, PHP_URL_HOST);
$msg = implode('', array(
$ts,
$nonce,
'GET',
$url_host,
'/user',
'443'
));
$byte_array = base64_decode($secret);
//echo $byte_array;
// Create signature
$mac = base64_encode(hash_hmac('sha256', utf8_encode($msg), $secret, true));
echo $mac;
$headers = array('Authorization: Id="' . $access_token . '", Nonce="' . $nonce . '", Ts="' . $ts .'", Mac="' . $mac . '"');
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL,"https://ishin-global.aktsk.com/user");
curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch1, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
curl_setopt($ch1, CURLOPT_AUTOREFERER, true);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch1, CURLOPT_VERBOSE, true);
echo "<pre>";
$server_output1 = curl_exec($ch1);
if(curl_errno($ch1)){
echo 'Request Error:' . curl_error($ch1);
}
var_dump($server_output1);
echo "</pre>";
curl_close ($ch1);
?>
</body>
</html>
I know it's two years later, but the port instead of 443 is 3001
The way you are doing it, is very different of my approach, so I don't know if there's something wrong in your code, for me it seems so, but I do not know where those two variables came from.
I use this to create the OAUTH2
$rn=chr(0x0A);
$secret=$signin['secret']; //this is from sign_in part that I assume you're getting right
$nonce=$requestepochtime.':'.md5('whateveryouwant');
$method='GET';
$url='/blablabla';
$hostname='the-url-without-the-http';
$port='3001'; //<- THIS ONE DROVE ME CRAZY
$RFC2616_string=
$requestepochtime.$rn.
$nonce.$rn.
$method.$rn.
$url.$rn.
$hostname.$rn.
$port.$rn.
''.$rn;
If you solved it at that time, maybe in global now you have to face the puzzle image.

PHP - Malformed result from curl_exec()

I've a problem with PHP function curl_exec(). I'm sending a SOAP request to an advice and the advice should return an SOAP reponse, but I just get a String without XML tags.
Okay, I'm using this code:
protected function _send_request($url,$post_string) {
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
if ( ($result = curl_exec($soap_do)) === false) {
echo curl_error($soap_do);
}
else {
echo("<pre>".$result."</pre>");
}
}
And the code seems to work. I captured the network traffic with Wireshark and the reponse in the TCP package is:
<?xml version='1.0' encoding='utf-8'?>
<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tds=\"http://www.onvif.org/ver10/device/wsdl\" xmlns:tt=\"http://www.onvif.org/ver10/schema\">
<s:Body>
<tds:GetSystemDateAndTimeResponse>
<tds:SystemDateAndTime>
<tt:DateTimeType>
Manual
</tt:DateTimeType>
<tt:DaylightSavings>
true
</tt:DaylightSavings>
<tt:TimeZone>
<tt:TZ>
CET-1CEST,M3.5.0,M10.5.0/3
</tt:TZ>
</tt:TimeZone>
<tt:UTCDateTime>
<tt:Time>
<tt:Hour>
13
</tt:Hour>
<tt:Minute>
26
</tt:Minute>
<tt:Second>
21
</tt:Second>
</tt:Time>
<tt:Date>
<tt:Year>
2014
</tt:Year>
<tt:Month>
2
</tt:Month>
<tt:Day>
5
</tt:Day>
</tt:Date>
</tt:UTCDateTime>
<tt:LocalDateTime>
<tt:Time>
<tt:Hour>
14
</tt:Hour>
<tt:Minute>
26
</tt:Minute>
<tt:Second>
21
</tt:Second>
</tt:Time>
<tt:Date>
<tt:Year>
2014
</tt:Year>
<tt:Month>
2
</tt:Month>
<tt:Day>
5
</tt:Day>
</tt:Date>
</tt:LocalDateTime>
</tds:SystemDateAndTime>
</tds:GetSystemDateAndTimeResponse>
</s:Body>
</s:Envelope>
Now the problem. echo $result just returns
ManualtrueCET-1CEST,M3.5.0,M10.5.0/3134622201425144622201425
The XML structure seems lost and I can't recreate it. I'm working with XAMPP PHP version 5.3.1 and the curl extension. Does anybody have an idea how to get the original XML structure?

Soap request using cURL and PHP

I'm trying to send a SOAP post via Curl in PHP but I always get a couldn't connect to host problem.
But when i trie to use the same URL in a web based client like hurl, a got the correct response :
Hurl Test :http://www.hurl.it
My code :
$url = "https://gateway.monster.com/bgwBroker";
$soapMessage = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' .
'<SOAP-ENV:Header>'.
'<mh:MonsterHeader xmlns:mh="http://schemas.monster.com/MonsterHeader">'.
'<mh:MessageData>'.
'<mh:MessageId>PresenceMedia SARL Jobs</mh:MessageId>'.
'<mh:Timestamp>2004-06-09T14:41:44Z</mh:Timestamp>'.
'</mh:MessageData>'.
'</mh:MonsterHeader>'.
'<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext">'.
'<wsse:UsernameToken>'.
'<wsse:Username>xrtpjobsx01</wsse:Username>'.
'<wsse:Password>rtp987654</wsse:Password>'.
'</wsse:UsernameToken>'.
'</wsse:Security>'.
'</SOAP-ENV:Header>'.
'<SOAP-ENV:Body>'.
'<Job jobRefCode="Job - minimal fields" jobAction="addOrUpdate" jobComplete="true" xmlns="http://schemas.monster.com/Monster" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.monster.com/Monster http://schemas.monster.com/Current/xsd/Monster.xsd">'.
'<RecruiterReference>'.
'<UserName>xrtpjobsx01</UserName>'.
'</RecruiterReference>'.
'<JobInformation>'.
'<JobTitle><![CDATA[PresenceMedia SARL its a simple test from morocco blablablablablablablablablablablabla]]></JobTitle>'.
'<JobStatus monsterId="4">JobTypeFullTime</JobStatus>'.
'<PhysicalAddress>'.
'<City>Rabat Shore</City>'.
'<State>NY</State>'.
'<CountryCode>US</CountryCode>'.
'<PostalCode>11220</PostalCode>'.
'</PhysicalAddress>'.
'<JobBody><![CDATA[PresenceMedia SARL Body blablabla blablabla blablabla blablabla blablabla blablabla blablabla]]></JobBody>'.
'</JobInformation>'.
'<JobPostings>'.
'<JobPosting>'.
'<Location>'.
'<City>London East</City>'.
'<State>London</State>'.
'<CountryCode>UK</CountryCode>'.
'</Location>'.
'<JobCategory monsterId="47" />'.
'<JobOccupations>'.
'<JobOccupation monsterId="11909" />'.
'</JobOccupations>'.
'<BoardName monsterId="1" />'.
'<Industries>'.
'<Industry>'.
'<IndustryName monsterId="1" />'.
'</Industry>'.
'</Industries>'.
'</JobPosting>'.
'</JobPostings>'.
'</Job>'.
'</SOAP-ENV:Body>'.
'</SOAP-ENV:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($soapMessage),
);
$soapUser = "xrtpjobsx01";
$soapPassword = "rtp987654";
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url);
curl_setopt($soap_do, CURLOPT_PORT, 8443);
curl_setopt($soap_do, CURLOPT_USERPWD, $soapUser.":".$soapPassword);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do,CURLOPT_TIMEOUT,9000);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soapMessage);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
echo "Result:" . $result;
echo "<br>Error:" . $err ;
echo "<b><pre>";
var_dump(curl_getinfo($soap_do));
echo "</pre>";
?>
In php use simple Soapclient to post reponse. and check he response also check if the port used for connection is free.
$client = new SoapClient($Url, $options);
$data = $client->functionName($params);

CURL server data transfer timeout

I am using the following code to get the xml data form icecat.biz:
set_time_limit (0);
$login = "Arpan";
$password = "arpan";
//$url="http://data.icecat.biz/export/freexml.int/EN/files.index.xml";
$url= "http://data.icecat.biz/export/level4/EN";
//$url="http://data.icecat.biz/export/freexml.int/DE/10.xml";
$user_agent = 'Mozilla/5.0 (Windows; U;
Windows NT 5.1; ru; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9';
$header = array(
"Accept: text/xml,application/xml,application/xhtml+xml,
text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
"Accept-Language: ru-ru,ru;q=0.7,en-us;q=0.5,en;q=0.3",
"Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7",
"Keep-Alive: 300");
$local_path = "myxml.xml";
$file_handle = fopen($local_path, "w");
ob_start();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $file_handle);
curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
curl_setopt($ch, CURLOPT_USERPWD, $login . ":" . $password);
curl_setopt($ch, CURLOPT_TIMEOUT, 0); // times out after 4s
//curl_setopt($c, CURLOPT_TIMEOUT, 2);
//curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//$head = curl_exec($ch);
$result = curl_exec ($ch);
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
ob_end_clean();
fclose ($file_handle);
$xmlStr = file_get_contents($local_path);
$xmlObj = simplexml_load_string($xmlStr);
print "<pre>";
//print_r($xmlObj->Product->ProductRelated->attributes()->ID);
print_r($xmlObj);
exit;
The page is being executed for a unlimited time but the XML is not being updated after 10 to 20 sec. The output xml is also not being completed. I think after a certain time the server is not responding or data is not being transferred.
Here is the error message:
**** The server xml (icecat) size is big
What is the problem and how do I fix it?
Sounds like you are not giving enough time for the request to download properly.
Uncomment your //curl_setopt($c, CURLOPT_TIMEOUT, 2);
And put the timeout to 600 for a test.
Beyond that your request looks fine, you could always check to see if the server is caching responses, the last thing that I've seen recently happening is if some of my users have reverse proxies in order to cache their normal operations. Where some truncated responses got cached and thats all they got back for a 24 hour period although that may not be related to you.

Categories