当前位置:Gxlcms > PHP教程 > PHPAPI获取天气预报,以及使用飞信API,给好友发_PHP教程

PHPAPI获取天气预报,以及使用飞信API,给好友发_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

API获取天气预报,以及使用飞信API,给好友发送短信
加上计划任务,就可以持续每天自动发送天气预报给自己和亲人啦。。。

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))//判断是不是文件上传 { $postBodyString .= "$k=" . urlencode($v) . "&"; } else//文件上传用multipart/form-data,否则用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获取天气预报,以及使用飞信API,给好友发送短信 加上计划任务,就可以持续每天自动发送天气预报给自己和亲人啦。。。 ?php#########...

人气教程排行