summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-01-15 07:57:40 -0800
committerAaron Parecki <aaron@parecki.com>2017-01-15 07:57:40 -0800
commitfa06932a9c1bb289cae6cbaa046c6b9c07bf5b1a (patch)
tree0ab59efc9ad700d092a40df9c65c42948f906a85 /lib
parentd87042ab9d05921e17dd2b3c320d199cfb067d65 (diff)
use XRay to parse tweets
Diffstat (limited to 'lib')
-rw-r--r--lib/helpers.php61
1 files changed, 1 insertions, 60 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index 8948f92..4a4da11 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -59,24 +59,9 @@ function k($a, $k, $default=null) {
}
}
-function get_timezone($lat, $lng) {
- try {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'http://atlas.p3k.io/api/timezone?latitude='.$lat.'&longitude='.$lng);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($ch);
- $tz = @json_decode($response);
- if($tz)
- return new DateTimeZone($tz->timezone);
- } catch(Exception $e) {
- return null;
- }
- return null;
-}
-
function display_url($url) {
$parts = parse_url($url);
- if($parts['path'] != '' && $parts['path'] != '/') {
+ if(isset($parts['path']) && $parts['path'] != '' && $parts['path'] != '/') {
return preg_replace('/^https?:\/\//','', $url);
} else {
return $parts['host'];
@@ -395,47 +380,3 @@ function correct_photo_rotation($filename) {
$image->writeImage($filename);
}
}
-
-function tweet_to_h_entry($tweet) {
- // Converts to XRay's h-entry format
-
- $entry = [
- 'type' => 'entry',
- 'url' => 'https://twitter.com/'.$tweet->user->screen_name.'/status/'.$tweet->id_str,
- ];
-
- $published = strtotime($tweet->created_at);
- $entry['published'] = date('c', $published);
-
- $entry['content'] = [
- 'text' => $tweet->text
- ];
-
- if($tweet->entities->urls) {
- foreach($tweet->entities->urls as $url) {
- $entry['content']['text'] = str_replace($url->url, $url->expanded_url, $entry['content']['text']);
- }
- }
-
- $entry['author'] = [
- 'type' => 'card',
- 'url' => 'https://twitter.com/'.$tweet->user->screen_name,
- 'name' => $tweet->user->name,
- 'nickname' => $tweet->user->screen_name,
- 'photo' => $tweet->user->profile_image_url_https
- ];
-
- if($tweet->user->url) {
- $entry['author']['url'] = $tweet->user->entities->url->urls[0]->expanded_url;
- }
-
- if($tweet->entities->hashtags) {
- $entry['category'] = [];
- foreach($tweet->entities->hashtags as $tag) {
- $entry['category'][] = $tag->text;
- }
- }
-
- return $entry;
-}
-