PHP API擷取天氣預報,以及使用飛信API,給好友發_PHP教程

來源:互聯網
上載者:User
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;}?>

http://www.bkjia.com/PHPjc/735146.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/735146.htmlTechArticleAPI擷取天氣預報,以及使用飛信API,給好友傳送簡訊 加上計劃任務,就可以持續每天自動發送天氣預報給自己和親人啦。。。 ?php#########...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.