forked from blallo/rss-bridge
[FacebookBridge] Support facebook links as user name
Allows users to paste facebook links as user name. The link must contain the correct host (www.facebook.com) and a valid path (/user-name/...). The first part of the path is used for the user name. Errors are returned in case something went wrong. References #706
This commit is contained in:
parent
4a5f190e0e
commit
5087f5f79e
1 changed files with 36 additions and 9 deletions
|
@ -127,6 +127,31 @@ application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscrip
|
||||||
if(is_null($html)) {
|
if(is_null($html)) {
|
||||||
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||||
|
|
||||||
|
// Check if the user provided a fully qualified URL
|
||||||
|
if (filter_var($this->getInput('u'), FILTER_VALIDATE_URL)) {
|
||||||
|
|
||||||
|
$urlparts = parse_url($this->getInput('u'));
|
||||||
|
|
||||||
|
if($urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||||
|
returnClientError('The host you provided is invalid! Received "'
|
||||||
|
. $urlparts['host']
|
||||||
|
. '", expected "'
|
||||||
|
. parse_url(self::URI)['host']
|
||||||
|
. '"!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!array_key_exists('path', $urlparts)
|
||||||
|
|| $urlparts['path'] === '/') {
|
||||||
|
returnClientError('The URL you provided doesn\'t contain the user name!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = explode('/', $urlparts['path'])[1];
|
||||||
|
|
||||||
|
$html = getSimpleHTMLDOM(self::URI . urlencode($user) . '?_fb_noscript=1', $header)
|
||||||
|
or returnServerError('No results for this query.');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
// First character cannot be a forward slash
|
// First character cannot be a forward slash
|
||||||
if(strpos($this->getInput('u'), "/") === 0) {
|
if(strpos($this->getInput('u'), "/") === 0) {
|
||||||
returnClientError('Remove leading slash "/" from the username!');
|
returnClientError('Remove leading slash "/" from the username!');
|
||||||
|
@ -139,6 +164,8 @@ application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscrip
|
||||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
||||||
or returnServerError('No results for this query.');
|
or returnServerError('No results for this query.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle captcha form?
|
//Handle captcha form?
|
||||||
|
|
Loading…
Reference in a new issue