IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/Http/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Http/WeatherApi.php

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Http;

class WeatherApi {

    static function fetch($city) {
        return self::initiateApi($city);
    }

    static function initiateApi($city){
        $url = 'https://api.openweathermap.org/data/2.5/forecast?appid=6dee0cb7efa5312a639ec1a54ca8bea8&units=metric&q='.$city.',IN';
        $ch = curl_init ();
        curl_setopt ( $ch, CURLOPT_URL, $url );
        curl_setopt ( $ch, CURLOPT_POST, true );
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );    
        $result = curl_exec ( $ch );
        if(curl_errno($ch)) return  curl_error($ch);
        curl_close ( $ch );
        return  $result;
    }

}

Copyright © 2021 - 2025 IMMREX7