fork download
  1. $request_xml = "<?xml version='1.0' encoding='utf-8'?>
  2. <request>
  3. <id>12345</id>
  4. <email>eoin@dolepaddy.com</email>
  5. <request>";
  6.  
  7. //Initialize handle and set options
  8. $username = 'dolepaddy';
  9. $password = 'secret123';
  10. $ch = curl_init();
  11. curl_setopt($ch, CURLOPT_URL, 'https://c...content-available-to-author-only...r.com/xmlrpc');
  12. curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
  13. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  16. curl_setopt($ch, CURLOPT_TIMEOUT, 4);
  17. curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml);
  18. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
  19.  
  20. //Execute the request and also time the transaction ( optional )
  21. $start = array_sum(explode(' ', microtime()));
  22. $result = curl_exec($ch);
  23. $stop = array_sum(explode(' ', microtime()));
  24. $totalTime = $stop - $start;
  25.  
  26. //Check for errors ( again optional )
  27. if ( curl_errno($ch) ) {
  28. $result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
  29. } else {
  30. $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
  31. switch($returnCode){
  32. case 200:
  33. break;
  34. default:
  35. $result = 'HTTP ERROR -> ' . $returnCode;
  36. break;
  37. }
  38. }
  39.  
  40. //Close the handle
  41. curl_close($ch);
  42.  
  43. //Output the results and time
  44. echo 'Total time for request: ' . $totalTime . "\n";
  45. echo $result;
Runtime error #stdin #stdout 0.02s 13664KB
stdin
Standard input is empty
stdout
Parse error: syntax error, unexpected T_STRING in /home/aTciDC/prog.php on line 1