Home > Backend Development > PHP Tutorial > PHP API to obtain weather forecast, and use Fetion API to send it to friends_PHP Tutorial

PHP API to obtain weather forecast, and use Fetion API to send it to friends_PHP Tutorial

WBOY
Release: 2016-07-13 10:37:47
Original
1184 people have browsed it

API to get weather forecast, and use Fetion API to send text messages to friends
With the addition of scheduled tasks, you can continue to automatically send weather forecasts to yourself and your loved ones every day. . .

5 && strtolower(substr($url,0,5)) == "https" ) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); } ​ if (is_array($postFields) && 0 < count($postFields)) { $postBodyString = ""; $postMultipart = false; foreach ($postFields as $k => $v) { if("@" != substr($v, 0, 1))//Determine whether it is a file upload { $postBodyString .= "$k=" . urlencode($v) . "&"; } else//Use multipart/form-data for file upload, otherwise use www-form-urlencoded { $postMultipart = true; } } unset($k, $v); curl_setopt($ch, CURLOPT_POST, true); if ($postMultipart) { curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); } else { curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1)); } } $reponse = curl_exec($ch); ​ if (curl_errno($ch)) { throw new Exception(curl_error($ch),0); } else { $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (200 !== $httpStatusCode) { throw new Exception($reponse,$httpStatusCode); } } curl_close($ch); return $reponse; } function object_to_array($obj) { $_arr = is_object($obj) ? get_object_vars($obj) : $obj; foreach ($_arr as $key => $val) { $val = (is_array($val) || is_object($val)) ? object_to_array($val) : $val; $arr[$key] = $val; } return $arr; } ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/735146.htmlTechArticleAPI to obtain weather forecasts, and use the Fetion API to send text messages to friends and add scheduled tasks, and you can continue to do so automatically every day Send weather forecasts to yourself and your loved ones. . . ?php#########...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template