Browse Source

First try to remove facebook

pull/107/head
Josemar Lohn 3 years ago
parent
commit
9ca78ab024
No known key found for this signature in database GPG Key ID: 441E69D80355E46F
6 changed files with 254 additions and 622 deletions
  1. +1
    -1
      .github/workflows/php.yml
  2. +5
    -15
      README.md
  3. +2
    -2
      composer.json
  4. +242
    -565
      composer.lock
  5. +1
    -2
      composer.production.json
  6. +3
    -37
      lib/XRay/Formats/Facebook.php

+ 1
- 1
.github/workflows/php.yml View File

@ -36,7 +36,7 @@ jobs:
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
run: composer update --prefer-dist --no-progress
- name: Run test suite
run: composer run-script test

+ 5
- 15
README.md View File

@ -13,7 +13,7 @@ XRay will parse content in the following formats. First the URL is checked again
* GitHub
* XKCD
* Hackernews
* Facebook (public events)
* ~~Facebook (public events)~~ <REMOVED>
If the contents of the URL is XML or JSON, then XRay will parse the Atom, RSS or JSONFeed formats.
@ -245,7 +245,7 @@ url=https://aaronparecki.com/2016/01/16/11/
&body=<html>....</html>
```
or for Twitter/GitHub/Facebook where you might have JSON,
or for Twitter/GitHub where you might have JSON,
```
POST /parse
@ -282,9 +282,9 @@ url=https://aaronparecki.com/2016/01/16/11/
### API Authentication
XRay uses the Twitter, Github and Facebook APIs to fetch posts, and those API require authentication. In order to keep XRay stateless, it is required that you pass in the credentials to the parse call.
XRay uses the Twitter and Github APIs to fetch posts, and those API require authentication. In order to keep XRay stateless, it is required that you pass in the credentials to the parse call.
You should only send the credentials when the URL you are trying to parse is a Twitter URL, a GitHub URL or a Facebook URL, so you'll want to check for whether the hostname is `twitter.com`, `github.com`, etc. before you include credentials in this call.
You should only send the credentials when the URL you are trying to parse is a Twitter URL or a GitHub URL, so you'll want to check for whether the hostname is `twitter.com`, `github.com`, etc. before you include credentials in this call.
#### Twitter Authentication
@ -304,16 +304,6 @@ XRay uses the GitHub API to fetch GitHub URLs, which provides higher rate limits
* `github_access_token` - A GitHub access token
#### Facebook Authentication
XRay uses the Facebook API to fetch Facebook URLs. You can create a Facebook App on Facebooks developer website.
* facebook_app_id - Your application's App ID
* facebook_app_secret - Your application's App Secret
At this moment, XRay is able to get it's own access token from those credentials.
### Error Response
```json
@ -431,7 +421,7 @@ Other properties are returned in the response at the same level as the `data` pr
* `mf2+json`
* `feed+json`
* `xml`
* `instagram`/`facebook`/`github`/`xkcd`
* `instagram`/`github`/`xkcd`
#### Feeds

+ 2
- 2
composer.json View File

@ -25,8 +25,8 @@
]
},
"require-dev": {
"league/plates": "3.*",
"league/route": "1.*",
"league/plates": "^3.0",
"league/route": "^1.0",
"phpunit/phpunit": "^8.0.0|^9.0.0"
},
"autoload-dev": {

+ 242
- 565
composer.lock
File diff suppressed because it is too large
View File


+ 1
- 2
composer.production.json View File

@ -15,7 +15,6 @@
"p3k/http": ">=0.1.8",
"cebe/markdown": "1.1.*",
"p3k/picofeed": ">=0.1.35",
"facebook/graph-sdk": "^5.5",
"masterminds/html5": "^2.3"
},
"autoload": {
@ -36,4 +35,4 @@
"require-dev": {
"phpunit/phpunit": "4.8.*"
}
}
}

+ 3
- 37
lib/XRay/Formats/Facebook.php View File

@ -79,46 +79,12 @@ class Facebook extends Format {
public static function fetch($url, $creds) {
$parts = self::extract_url_parts($url);
if(!$parts or $parts['api_uri'] == false) {
return [
'error' => 'unsupported_url',
'error_description' => 'This Facebook URL is not supported',
'error_code' => 400,
];
}
$fb = new \Facebook\Facebook(array(
'app_id' => $creds['facebook_app_id'],
'app_secret' => $creds['facebook_app_secret'],
'default_graph_version' => 'v2.9',
));
$fbApp = new \Facebook\FacebookApp($creds['facebook_app_id'], $creds['facebook_app_secret']);
$token = $fbApp->getAccessToken();
$request = new \Facebook\FacebookRequest($fbApp, $token, 'GET', $parts['api_uri']);
try {
$response = $fb->getClient()->sendRequest($request);
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
return [
'error' => 'facebook_graph_error',
'error_description' => 'Graph returned an error: ' . $e->getMessage(),
'error_code' => 400,
];
} catch(\Facebook\Exceptions\FacebookSDKException $e) {
return [
'error' => 'facebook_sdk_error',
'error_description' => 'Facebook SDK returned an error: ' . $e->getMessage(),
'error_code' => 400,
];
}
//Disabled Function for now
//TODO: Search all references to this class and remove it.
return [
'code' => 200,
'body' => $response->getDecodedBody(),
'body' => '',
'url' => $url
];
}

Loading…
Cancel
Save