BroadwayAPI is a PHP class to extract / export channel playlists and EPG from the PCTV Broadway. These can be reused with OpenELEC, XBMC, Kodi and the IPTV Simple PVR Client Addon.
I am using the setup on a local server to handle playlists and epg updates for multiple XBMC setups.
https://bitbucket.org/portalzine/cubicfusion-broadwayapi
This is a project in progress. More details soon…
Enjoy
Alex
Debugging can be such a pain sometimes. Kint has saved my bacon more than once ;)
WPML for WordPress is a powerful plugin to build a multi-language setup. But it still comes short in some areas, especially when it comes to a custom integration into plugins or when using custom post-types.
Normally this function should return the id of the linked translated content, but has not worked for me in some cases (especially when AJAX is involved).
1 |
icl_object_id( $id, 'custom_post_type', false, $translation_lang ); |
A simple SELECT helps to get that id yourself :)
1 2 3 4 5 6 7 8 |
// original_id - main post id // $translation_lang - translated language code ... de, nl ... global $wpdb; $translation = $wpdb->get_results("SELECT * from wp_icl_translations where trid = (SELECT trid from wp_icl_translations where element_id = '".$original_id."' and element_type='post_page') and language_code='".$translation_lang."'"); $post = get_post($translation[0]->element_id, ARRAY_A); |
The GitHub repository from Saša Stamenković provides a nice list of all countries with names and ISO 3166-1 codes.
Available formats are:
Sometimes when personalizing or translating interfaces, IP geolocation is required.
Besides their subscription based products Maxmind also provides a free IP Geolocation database set. The set is offered under the Creative Commons Attribution-ShareAlike 3.0 Unported License. The free databases maps IPv4 + IPv6 addresses and is being updated once a month. GeoLite Free Downloadable Databases
Another free set of data is provided by IP2location Lite. It is free for personal or commercial use with attribution required
The JSON spec allows integers, fractional numbers, strings, arrays, but when it comes to dates things are handled differently. There really is no date format in the JSON spec. Would be nice if every JSON date output would conform to ISO8601 :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Ruby 2011-07-14 19:43:37 +0100 //ISO 8601 2011-07-14T19:43:37+0100 // Javascript Date Object new Date(1310669017000) // Javascript built-in JSON object 2012-04-23T18:25:43.511Z // .NET JavaScriptSerializer Date(1310669017000) // .NET DataContractJsonSerializer Date(1335205592410-0500) |
Some of these can easily be converted to a PHP timestamp using strtotime(), others require some more magic.
Here is a way to transform the .NET variant, something that has been haunting me in a current project ;)
1 2 3 4 |
preg_match('~(\d+)\d{3}((?:\+|-)\d+)~', $date, $match); $dt = new DateTime('@' . $match[1]); $dt = new DateTime($dt->format('Y-m-d H:i:s') . ' ' . $match[2]); $date = strtotime($dt->format('r')); |
Due to the wide usage of JSON as an exchange format, I really hope we will see a spec update in the future :)
The Google App Engine has no cURL support, which means that all REST calls need to be executed using file_get_contents.
As Parse REST calls need to be secure, you need to make sure that you send the request with a proper SSL context.
Short example of adding data using the Parse REST API from a Google App Engine application:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$data = array('data1' => 1113, 'data2' => 'Alex', 'data3' => false); $context = array( "ssl"=>array( "allow_self_signed"=>true, "verify_peer"=>false, ), 'http'=> array( "method" => "post", "header" => "X-Parse-Application-Id: YourAppID\r\n" . "X-Parse-REST-API-Key: YourRESTID\r\n" . "Content-Type: application/json\r\n", "content" => json_encode($data) ) ); $context = stream_context_create($context); $result = file_get_contents("https://api.parse.com/1/classes/yourClass", false, $context); |
1 2 3 4 5 |
function get_linkedin() { $json_string = $this->file_get_contents_curl("http://www.linkedin.com/countserv/count/share?url=$this->url&format=json"); $json = json_decode($json_string, true); return isset($json['count'])?intval($json['count']):0; } |
Shares only
1 2 3 4 5 |
function get_likes($url) { $json_string = file_get_contents('http://graph.facebook.com/?ids=' . $url); $json = json_decode($json_string, true); return intval( $json[$url]['shares'] ); } |
Shares & Likes
1 2 3 4 5 6 7 8 9 10 11 12 |
function get_likes($url) { $json_string = file_get_contents(‘http://graph.facebook.com/?ids=’ . $url); $json = json_decode($json_string, true); $like_count = 0; if (isset($json[$url]['shares'])) $like_count += intval($json[$url]['shares']); if (isset($json[$url]['likes'])) $like_count += intval($json[$url]['likes']); return $like_count; } |
1 2 3 4 5 |
function get_tweets($url) { $json_string = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $url); $json = json_decode($json_string, true); return intval( $json['count'] ); } |