From 44f91f443adb24d7f325c1870ac6d94315ab07de Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Fri, 28 Jan 2022 08:39:44 -0800 Subject: [PATCH] remove facebook --- README.md | 1 - controllers/Parse.php | 1 - lib/XRay/Fetcher.php | 25 ---- lib/XRay/Formats/Facebook.php | 107 ------------------ lib/XRay/Parser.php | 4 - .../graph.facebook.com/1596554663924436.json | 1 - .../graph.facebook.com/446197069049722.json | 1 - 7 files changed, 140 deletions(-) delete mode 100644 lib/XRay/Formats/Facebook.php delete mode 100644 tests/data/graph.facebook.com/1596554663924436.json delete mode 100644 tests/data/graph.facebook.com/446197069049722.json diff --git a/README.md b/README.md index e8bf65c..0df9ed6 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ XRay will parse content in the following formats. First the URL is checked again * GitHub * XKCD * Hackernews -* ~~Facebook (public events)~~ If the contents of the URL is XML or JSON, then XRay will parse the Atom, RSS or JSONFeed formats. diff --git a/controllers/Parse.php b/controllers/Parse.php index c5ecfff..2cb8260 100644 --- a/controllers/Parse.php +++ b/controllers/Parse.php @@ -95,7 +95,6 @@ class Parse { $fields = [ 'twitter_api_key','twitter_api_secret','twitter_access_token','twitter_access_token_secret', - 'facebook_app_id', 'facebook_app_secret', 'github_access_token', 'token' ]; diff --git a/lib/XRay/Fetcher.php b/lib/XRay/Fetcher.php index c1931e2..5d7877a 100644 --- a/lib/XRay/Fetcher.php +++ b/lib/XRay/Fetcher.php @@ -43,11 +43,6 @@ class Fetcher { return $this->_fetch_tweet($url, $opts); } - // Check if this is a Facebook URL and use the API - if(Formats\Facebook::matches_host($url)) { - return $this->_fetch_facebook($url, $opts); - } - // Transform the HTML GitHub URL into an GitHub API request and fetch the API response if(Formats\GitHub::matches_host($url)) { return $this->_fetch_github($url, $opts); @@ -181,26 +176,6 @@ class Fetcher { return Formats\Twitter::fetch($url, $creds); } - private function _fetch_facebook($url, $opts) { - $fields = ['facebook_app_id','facebook_app_secret']; - $creds = []; - foreach($fields as $f) { - if(isset($opts[$f])) - $creds[$f] = $opts[$f]; - } - - if(count($creds) < 2) { - return [ - 'error_code' => 400, - 'error' => 'missing_parameters', - 'error_description' => 'Both Facebook credentials must be included in the request' - ]; - } - - // TODO: Question, should I do this like Twitter or like Github? - return Formats\Facebook::fetch($url, $creds); - } - private function _fetch_github($url, $opts) { $fields = ['github_access_token']; $creds = []; diff --git a/lib/XRay/Formats/Facebook.php b/lib/XRay/Formats/Facebook.php deleted file mode 100644 index 3aa95ed..0000000 --- a/lib/XRay/Formats/Facebook.php +++ /dev/null @@ -1,107 +0,0 @@ - 'event', - 'url' => $url, - 'name' => $fbObject['name'], - 'start' => $fbObject['start_time'] - ); - - if(isset($fbObject['end_time'])) $event['end'] = $fbObject['end_time']; - if(isset($fbObject['description'])) $event['summary'] = $fbObject['description']; - - // Is the event linked to a Page? - if(isset($fbObject['place']['id'])) { - - $card = array( - 'type' => 'card', - 'url' => 'https://facebook.com/'.$fbObject['place']['id'], - 'name' => $fbObject['place']['name'] - ); - - if(isset($fbObject['place']['location'])) { - - $location = $fbObject['place']['location']; - - if(isset($location['zip'])) $card['postal-code'] = $location['zip']; - if(isset($location['city'])) $card['locality'] = $location['city']; - if(isset($location['state'])) $card['region'] = $location['state']; - if(isset($location['street'])) $card['street-address'] = $location['street']; - if(isset($location['country'])) $card['country'] = $location['country']; - if(isset($location['latitude'])) $card['latitude'] = (string)$location['latitude']; - if(isset($location['longitude'])) $card['longitude'] = (string)$location['longitude']; - - } - - $event['location'] = $card['url']; - $event['refs'] = array($card); - - // If we only have a name, use that - } elseif(isset($fbObject['place']['name'])) { - $event['location'] = $fbObject['place']['name']; - } - - $event['post-type'] = \p3k\XRay\PostType::discover($event); - - return [ - 'data' => $event, - 'original' => $fbObject, - 'source-format' => 'facebook', - ]; - } - } - - public static function fetch($url, $creds) { - - //Disabled Function for now - //TODO: Search all references to this class and remove it. - - return [ - 'code' => 200, - 'body' => '', - 'url' => $url - ]; - } - - private static function extract_url_parts($url) { - $response = false; - - if(preg_match('~https://(.*?).?facebook.com/([^/]+)/posts/(\d+)/?$~', $url, $match)) { - // TODO: how do we get these? - // $response['type'] = 'entry'; - // $response['api_uri'] = false; - - } elseif(preg_match('~https://(.*?).?facebook.com/events/(\d+)/?$~', $url, $match)) { - $response['type'] = 'event'; - $response['api_uri'] = '/'.$match[2]; - } - - return $response; - } -} diff --git a/lib/XRay/Parser.php b/lib/XRay/Parser.php index dc147ce..45b4eb9 100644 --- a/lib/XRay/Parser.php +++ b/lib/XRay/Parser.php @@ -91,10 +91,6 @@ class Parser { return Formats\Twitter::parse($http_response); } - if(Formats\Facebook::matches($url)) { - return Formats\Facebook::parse($http_response); - } - if(Formats\XKCD::matches($url)) { return Formats\XKCD::parse($http_response); } diff --git a/tests/data/graph.facebook.com/1596554663924436.json b/tests/data/graph.facebook.com/1596554663924436.json deleted file mode 100644 index aeb5f61..0000000 --- a/tests/data/graph.facebook.com/1596554663924436.json +++ /dev/null @@ -1 +0,0 @@ -{"description":"Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with like-minded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project. \n\n Contact (914) 414-1775 when you arrive to be admitted. \n\n\nMore information: \u0040[NjQyMTgzOTU5MjA4MTA3Omh0dHBzXGEvL2luZGlld2ViY2FtcC5jb20vZXZlbnRzLzIwMTUtMDQtMjItaG9tZWJyZXctd2Vic2l0ZS1jbHViOjo=:\u0040[NjQyMTgzOTU5MjA4MTA3Omh0dHBzXGEvL2luZGlld2ViY2FtcC5jb20vZXZlbnRzLzIwMTUtMDQtMjItaG9tZWJyZXctd2Vic2l0ZS1jbHViOjo=:https:\/\/indiewebcamp.com\/events\/2015-04-22-homebrew-website-club]]","name":"Homebrew Website Club","place":{"name":"Charging Bull - WeeWork - 25 Broadway, New York, NY 10004"},"start_time":"2015-04-22T19:00:00-0400","id":"1596554663924436"} \ No newline at end of file diff --git a/tests/data/graph.facebook.com/446197069049722.json b/tests/data/graph.facebook.com/446197069049722.json deleted file mode 100644 index 7818a4d..0000000 --- a/tests/data/graph.facebook.com/446197069049722.json +++ /dev/null @@ -1 +0,0 @@ -{"description":"The seventh annual gathering for independent web creators of all kinds, from graphic artists, to designers, UX engineers, coders, hackers, to share ideas, actively work on creating for their own personal websites, and build upon each others creations.\n\nIMPORTANT: Please register for a ticket from https:\/\/2017.indieweb.org\/ to attend! RSVPing on Facebook is not enough. Your registration will ensure that we get enough food for everyone!\n\nOriginally posted at https:\/\/aaronparecki.com\/2017\/06\/24\/1\/indieweb-summit","end_time":"2017-06-25T18:00:00-0700","name":"IndieWeb Summit","place":{"name":"Mozilla PDX","location":{"city":"Portland","country":"United States","latitude":45.5233192,"longitude":-122.6824722,"state":"OR","street":"1120 NW Couch St, Ste 320","zip":"97209"},"id":"332204056925945"},"start_time":"2017-06-24T09:00:00-0700","id":"446197069049722"} \ No newline at end of file