I want to use PHP cURL to access the WeatherWS official website. Example of the request: {code ...} code I wrote: {code ...} if it is a free user, theUserID is left blank, but the execution structure is {code ...} if theUserID is not added, the message {code...} is displayed ...} solution ?? I want to use PHP cURL to access WeatherWS
Request example provided on the official website:
POST /WebServices/WeatherWS.asmx/getWeather HTTP/1.1Host: www.webxml.com.cnContent-Type: application/x-www-form-urlencodedContent-Length: lengththeCityCode=string&theUserID=string
Code I wrote:
$ Data = 'thecitycode = Guangzhou & theUserID = "" '; $ curlObj = curl_init (); curl_setopt ($ curlObj, CURLOPT_URL, 'HTTP: // response '); curl_setopt ($ curlObj, CURLOPT_HEADER, 0); curl_setopt ($ curlObj, expires, 1); curl_setopt ($ curlObj, CURLOPT_POST, 1); curl_setopt ($ curlObj, expires, $ data); curl_setopt ($ curlObj, CURLOPT_HTTPHEADER, array ("application/x-www-form-u Rlencoded; charset = UTF-8 "," Content-length: ". strlen ($ data); $ rtn = curl_exec ($ curlObj); if (! Curl_errno ($ curlObj) {echo $ rtn;} else {echo 'curl error: '. curl_error ($ curlObj);} curl_close ($ curlObj );
If it is a free user, theUserID is left blank, but the execution structure is
Error detected: user verification failed. Http://www.webxml.com.cn/
If theUserID is not added, the following message is displayed:
The parameter theUserID is missing.
Solution ??
Reply content:
I want to use PHP cURL to access WeatherWS
Request example provided on the official website:
POST /WebServices/WeatherWS.asmx/getWeather HTTP/1.1Host: www.webxml.com.cnContent-Type: application/x-www-form-urlencodedContent-Length: lengththeCityCode=string&theUserID=string
Code I wrote:
$ Data = 'thecitycode = Guangzhou & theUserID = "" '; $ curlObj = curl_init (); curl_setopt ($ curlObj, CURLOPT_URL, 'HTTP: // response '); curl_setopt ($ curlObj, CURLOPT_HEADER, 0); curl_setopt ($ curlObj, expires, 1); curl_setopt ($ curlObj, CURLOPT_POST, 1); curl_setopt ($ curlObj, expires, $ data); curl_setopt ($ curlObj, CURLOPT_HTTPHEADER, array ("application/x-www-form-u Rlencoded; charset = UTF-8 "," Content-length: ". strlen ($ data); $ rtn = curl_exec ($ curlObj); if (! Curl_errno ($ curlObj) {echo $ rtn;} else {echo 'curl error: '. curl_error ($ curlObj);} curl_close ($ curlObj );
If it is a free user, theUserID is left blank, but the execution structure is
Error detected: user verification failed. Http://www.webxml.com.cn/
If theUserID is not added, the following message is displayed:
The parameter theUserID is missing.
Solution ??
Let's take a look at it by yourself. [how can we handle timeout errors?] I really don't know how to say it. It's difficult to read documents.
A large number of simple interfaces are not needed on the Internet.
: