By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

php curl_exec() method reports Error 500 on Alibaba Cloud

P: 51
Recently when I worked on the feature of scanning a QR code to make a Tmall payment, the curl_exec function always gave an Error 500 report after I coded an order on WeChat and then initiated a request to WeChat using curl, with no other error details provided. I tested the feature locally on Alibaba Cloud servers and it worked fine. But now the customer wanted to move the program on Alibaba Cloud web hosting, and this problem keeps emerging. I have confirmed that curl is on and available, and I have set display_errors and error_reporting to “Display all errors”. However:
1. Other than “Error 500”, no error details are shown.
2. Only the access logs are visible for the host, with no error logs available. The php.ini settings and apache settings are also not visible or changeable.
3. I cannot skip this error using @ or try catch, and curl resource parameters are not correct (I printed every single parameter).
To sum up, I still cannot locate this error and am anticipating some guidance from other programmers.
Expand|Select|Wrap|Line Numbers
  1.         $ch = curl_init();
  2.         //Setting timed out
  3.         curl_setopt($ch, CURLOPT_TIMEOUT, $second);
  4.  
  5.         //Set a proxy here if applicable
  6.         if(WxPayConfig::getValue('curl_proxy_host') != "0.0.0.0" 
  7.             && WxPayConfig::getValue('curl_proxy_port') != 0){
  8.             curl_setopt($ch,CURLOPT_PROXY, WxPayConfig::getValue('curl_proxy_host'));
  9.             curl_setopt($ch,CURLOPT_PROXYPORT, WxPayConfig::getValue('curl_proxy_port'));
  10.         }
  11.         curl_setopt($ch,CURLOPT_URL, $url);
  12.         curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
  13.         curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//Perform a strict verification
  14.         //Set the header
  15.         curl_setopt($ch, CURLOPT_HEADER, FALSE);
  16.         //The result must be a string and be output to the screen
  17.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  18.  
  19.         if($useCert == true){
  20.             //Set the certificate
  21.             //Use the certificate: cert and key belong to two .pem files separately.
  22.             curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM');
  23.             curl_setopt($ch,CURLOPT_SSLCERT, WxPayConfig::getValue('sslcert_path'));
  24.             curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM');
  25.             curl_setopt($ch,CURLOPT_SSLKEY, WxPayConfig::getValue('sslkey_path'));
  26.         }
  27.         //Post submission
  28.         curl_setopt($ch, CURLOPT_POST, TRUE);
  29.         curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  30.         //Run the curl
  31.         $data = curl_exec($ch);
  32.         //Return the result
  33.         if($data){
  34.             curl_close($ch);
  35.             return $data;
  36.         } else { 
  37.             $error = curl_errno($ch);
  38.             curl_close($ch);
  39.             throw new WxPayException("Curl error. Error code: $error");
  40.         }
Apr 25 '18 #1
Share this Question
Share on Google+
1 Reply


P: 34
In general, web hosting allows you to view the error log, but only the last several logs.
I guess that this is because of limited memory size. You can open a ticket for inquiry.
Apr 26 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.