Skip to content

Instantly share code, notes, and snippets.

@tinnvec
Last active October 6, 2016 17:03
Show Gist options
  • Select an option

  • Save tinnvec/48e17b1e2d1a91932b62196981801c63 to your computer and use it in GitHub Desktop.

Select an option

Save tinnvec/48e17b1e2d1a91932b62196981801c63 to your computer and use it in GitHub Desktop.
<?php
error_reporting(0);
$xml = simplexml_load_string(file_get_contents('http://www.dailytechnewsshow.com/category/headlines/feed/'));
$latest = $xml->channel->item[0];
parse_str(parse_url($latest->guid->__toString())['query'], $uid);
$latest_arr = array(
'uid' => $uid['p'],
'updateDate' => date_format(date_create($latest->pubDate->__toString()), "Y-m-d\TH:i:s.0\Z"),
'titleText' => customCharsConvert($latest->title->__toString()),
'mainText' => "",
'streamUrl' => str_replace('http:', 'https:', $latest->enclosure['url']->__toString()),
'redirectionUrl' => $latest->link->__toString()
);
header("Content-Type: application/json");
echo(json_encode($latest_arr, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
function customCharsConvert($str) {
$str = str_replace('–', '-', $str);
$str = str_replace('’', '\'', $str);
$str = str_replace('‘', '\'', $str);
return utf8_encode($str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment