forked from blallo/rss-bridge
bridges: Fix bridges with custom headers and options
This commit fixes bridges which called getContents, getSimpleHTMLDOM or getSimpleHTMLDOMCached with custom settings.
This commit is contained in:
parent
ee78e7613f
commit
6caca4946b
4 changed files with 18 additions and 44 deletions
|
@ -64,13 +64,11 @@ class Arte7Bridge extends BridgeAbstract {
|
||||||
. $lang
|
. $lang
|
||||||
. ($category != null ? '&category.code=' . $category : '');
|
. ($category != null ? '&category.code=' . $category : '');
|
||||||
|
|
||||||
$context = array(
|
$header = array(
|
||||||
'http' => array(
|
'Authorization: Bearer ' . self::API_TOKEN
|
||||||
'header' => 'Authorization: Bearer '. self::API_TOKEN
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$input = getContents($url, false, stream_context_create($context)) or die('Could not request ARTE.');
|
$input = getContents($url, $header) or die('Could not request ARTE.');
|
||||||
$input_json = json_decode($input, true);
|
$input_json = json_decode($input, true);
|
||||||
|
|
||||||
foreach($input_json['videos'] as $element) {
|
foreach($input_json['videos'] as $element) {
|
||||||
|
|
|
@ -96,17 +96,15 @@ class FacebookBridge extends BridgeAbstract {
|
||||||
$captcha_action = $_SESSION['captcha_action'];
|
$captcha_action = $_SESSION['captcha_action'];
|
||||||
$captcha_fields = $_SESSION['captcha_fields'];
|
$captcha_fields = $_SESSION['captcha_fields'];
|
||||||
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
|
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
|
||||||
$http_options = array(
|
|
||||||
'http' => array(
|
$header = array("Content-type:
|
||||||
'method' => 'POST',
|
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n");
|
||||||
'user_agent' => ini_get('user_agent'),
|
$opts = array(
|
||||||
'header' => array("Content-type:
|
CURLOPT_POST => 1,
|
||||||
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n"),
|
CURLOPT_POSTFIELDS => http_build_query($captcha_fields)
|
||||||
'content' => http_build_query($captcha_fields)
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
$context = stream_context_create($http_options);
|
|
||||||
$html = getContents($captcha_action, false, $context);
|
$html = getContents($captcha_action, $header, $opts);
|
||||||
|
|
||||||
if($html === false) {
|
if($html === false) {
|
||||||
returnServerError('Failed to submit captcha response back to Facebook');
|
returnServerError('Failed to submit captcha response back to Facebook');
|
||||||
|
@ -120,15 +118,7 @@ class FacebookBridge extends BridgeAbstract {
|
||||||
|
|
||||||
//Retrieve page contents
|
//Retrieve page contents
|
||||||
if(is_null($html)) {
|
if(is_null($html)) {
|
||||||
$http_options = array(
|
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||||
'http' => array(
|
|
||||||
'method' => 'GET',
|
|
||||||
'user_agent' => ini_get('user_agent'),
|
|
||||||
'header' => 'Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$context = stream_context_create($http_options);
|
|
||||||
|
|
||||||
// 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) {
|
||||||
|
@ -136,14 +126,10 @@ class FacebookBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!strpos($this->getInput('u'), "/")) {
|
if(!strpos($this->getInput('u'), "/")) {
|
||||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1',
|
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', $header)
|
||||||
false,
|
|
||||||
$context)
|
|
||||||
or returnServerError('No results for this query.');
|
or returnServerError('No results for this query.');
|
||||||
} else {
|
} else {
|
||||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1',
|
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
||||||
false,
|
|
||||||
$context)
|
|
||||||
or returnServerError('No results for this query.');
|
or returnServerError('No results for this query.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,19 +109,9 @@ class VkBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
ini_set('user-agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0');
|
ini_set('user-agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0');
|
||||||
|
|
||||||
$opts = array(
|
$header = array("Accept-language: en\r\nCookie: remixlang=3\r\n");
|
||||||
'http' => array(
|
|
||||||
'method' => "GET",
|
|
||||||
'user_agent' => ini_get('user_agent'),
|
|
||||||
'accept_encoding' => 'gzip',
|
|
||||||
'header' => "Accept-language: en\r\n
|
|
||||||
Cookie: remixlang=3\r\n"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$context = stream_context_create($opts);
|
return getContents($this->getURI(), $header);
|
||||||
|
|
||||||
return getContents($this->getURI(), false, $context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,8 @@ class YoutubeBridge extends BridgeAbstract {
|
||||||
private function ytGetSimpleHTMLDOM($url){
|
private function ytGetSimpleHTMLDOM($url){
|
||||||
return getSimpleHTMLDOM($url,
|
return getSimpleHTMLDOM($url,
|
||||||
$use_include_path = false,
|
$use_include_path = false,
|
||||||
$context = null,
|
$header = array(),
|
||||||
$offset = 0,
|
$opts = array(),
|
||||||
$maxLen = null,
|
$maxLen = null,
|
||||||
$lowercase = true,
|
$lowercase = true,
|
||||||
$forceTagsClosed = true,
|
$forceTagsClosed = true,
|
||||||
|
|
Loading…
Reference in a new issue