Skip to content

Instantly share code, notes, and snippets.

View quangpro1610's full-sized avatar
🏠
Working from home

Hoang Quang quangpro1610

🏠
Working from home
View GitHub Profile
@quangpro1610
quangpro1610 / open-weather-map-api.php
Last active June 5, 2021 10:24
The API for Weather
<?php
header('Content-Type: application/json; charset=utf-8');
$api_key = 'PUT YOUR API HERE';
if(!empty($_GET['province'])){
$province = $_GET['province'];
}else{
$province = 'Quang Tri';
}
$url = 'http://api.openweathermap.org/data/2.5/forecast?q=' . $province . ',vietnam&appid=' . $api_key . '&units=metric&lang=vi';
$content = file_get_contents($url);
<?php
/**
* Add meta fields support in rest API for post type `Post`
*
* This function will allow custom parameters within API request URL. Add post meta support for post type `Post`.
*
* > How to use?
* http://mysite.com/wp-json/wp/v2/posts?meta_key=<my_meta_key>&meta_value=<my_meta_value>
*
* > E.g. Get posts which post meta `already-visited` value is `true`.