Jump to content

creativeplanit

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by creativeplanit

  1. Hallelujah! ...Working code $curl = curl_init($url); if($curl){ $customHeader = array( "Authorization: Basic " . base64_encode(COMPANY_USERNAME . ":" . COMPANY_PASSWORD) ); $curlOptArr = array( CURLOPT_HTTPGET => TRUE, CURLOPT_HTTPHEADER => $customHeader, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_USERAGENT => 'CuRL Request', CURLOPT_SSL_VERIFYPEER => FALSE ); curl_setopt_array($curl, $curlOptArr); //$info = curl_getinfo($curl); $response = curl_exec($curl); $errRet = curl_error($curl); curl_close($curl); return $response; } I had to include the :CURLOPT_SSL_VERIFYPEER => FALSE:" option Since unable to verify SSl certificate, I was getting the following error: 60 - SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Even though the certificate for the server I am trying to connect to is probably valid. The alternate solution as explained here requires path to certificate (not an option). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/BuiltinObjectToken-EquifaxSecureCA.crt"); Anyway..Thanks much
  2. Sorry, no. Yahoo doesn't allow editing of php.ini files
  3. Thank you for your response Pikachu2000. I modified the error reporting lines as suggested..and... error returned as Warning: file_get_contents() [function.file-get-contents]: https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /status-yahoo.php on line 29 Warning: file_get_contents(https://xxxxxxxxxx.x...go=xxxxxxxxxxxx) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /status-yahoo.php on line 29 So, I did some searching and came up with the following: <?php $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, ‘http://www.cnn.com’); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $contents = curl_exec($ch); curl_close($ch); // display file echo $contents; ?> ..but I' not sure how to handle passing $context (the authorization).
  4. Hello, I'm hoping someone will be able to help with this issue I'm having. I'm a fairly new PHP user so this is a bit outside my abilities. Any assistance would be much appreciated. The Situation: A script hosted on Yahoo Small Business that submits a query to a third-party site and returns shipment tracking data. When I run the script on my local web server, the data is returned correctly. However when I run it from Yahoo hosting environment, no data is returned for the same query parameters. The Response Header: Server:YTS/1.19.11 P3P:policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV" Date:Thu, 15 Nov 2012 13:14:05 GMT Content-Type:text/html Connection:close Age:2 The script provided by Vendor (Full code is attached..) checkstatus.txt <?php // Error reporting (comment out for debug) //error_reporting(E_ALL); //ini_set("display_errors", 1); // Disable all errors and warnings (comment out in debug) error_reporting(0); define("COMPANY_URL", "https://xxxx.xxxxxxx.xxxxx/cargoQuery?"); // Change second argument to company URL define("COMPANY_USERNAME", "xxxxxxxx"); // Change the second argument to company username define("COMPANY_PASSWORD", "xxxxxxxx"); // Change the second argument to company password // --------------------------------- DO NOT EDIT BELOW THIS LINE --------------------------------- function get_request($url) { $context = stream_context_create(array( 'http' => array( 'method' => "GET", 'header' => sprintf("Authorization: Basic %s\r\n", base64_encode(COMPANY_USERNAME . ":" . COMPANY_PASSWORD)) ), )); $response = file_get_contents($url, false, $context); return $response; } $indicators = array('1' => 'Message Content Accepted', '2' => 'Message Content Rejected with comment', '4' => 'Goods Released', '5' => 'Goods required for examination - referred', '8' => 'Goods May Move under Customs transfer, Detain at Destination (CFIA)', '9' => 'Declaration Accepted, Awaiting arrival of goods.', '14' => 'Error message', '23' => 'Authorised to deliver CSA Shipment', '34' => 'Transaction awaiting processing'); $cargoNum = (trim($_GET['cargo']) != "") ? "cargo=" . strtoupper(trim($_GET['cargo'])) : ""; $transNum = (trim($_GET['transaction']) != "") ? "transaction=" .(trim($_GET['transaction'])) : ""; $data = trim(get_request(COMPANY_URL . $cargoNum . $transNum)); ?> ............... <?php if (!empty($data)) { echo "Data returned!"; $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; $doc->loadXML($data); $messages = $doc->getElementsByTagName('rns'); $hasAttributes = FALSE; $duplicates = Array(); foreach ($messages as $rns) { $hasAttributes = TRUE; $releaseDate = $rns->getAttribute('release_date'); if (in_array($releaseDate, $duplicates)) { continue; } array_push($duplicates, $releaseDate); $ind = $rns->getAttribute('processing_ind'); ?> <tr> <td> <div style="color: #2f2f2f;"> <?= $rns->getAttribute('transaction_num') ?> </div> </td> <td> <div style="color: #2f2f2f;"> <?= $rns->getAttribute('cargo_ctl_num') ?> </div> </td> <td> <div style="color: #2f2f2f;"> <?= $releaseDate ?> </div> </td> <td> <div style="color: #2f2f2f;"> <?= $rns->getAttribute('port') ?> </div> </td> <td> <div style="color: #2f2f2f;"> <?= (array_key_exists($ind, $indicators)) ? $indicators[$ind] : $ind ?> </div> </td> </tr> <?php } } if (!$hasAttributes) { ?> <tr> <td colspan="5"> <p><b>No data to display.</b></p> </td> </tr> <?php } ?> ...... The Environment Yahoo is running PHP 5.3.6 My local server: PHP 5.3.1 Apache 2.2.14
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.