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
|
||||
. ($category != null ? '&category.code=' . $category : '');
|
||||
|
||||
$context = array(
|
||||
'http' => array(
|
||||
'header' => 'Authorization: Bearer '. self::API_TOKEN
|
||||
)
|
||||
$header = array(
|
||||
'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);
|
||||
|
||||
foreach($input_json['videos'] as $element) {
|
||||
|
|
|
@ -96,17 +96,15 @@ class FacebookBridge extends BridgeAbstract {
|
|||
$captcha_action = $_SESSION['captcha_action'];
|
||||
$captcha_fields = $_SESSION['captcha_fields'];
|
||||
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
|
||||
$http_options = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'user_agent' => ini_get('user_agent'),
|
||||
'header' => array("Content-type:
|
||||
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n"),
|
||||
'content' => http_build_query($captcha_fields)
|
||||
),
|
||||
|
||||
$header = array("Content-type:
|
||||
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n");
|
||||
$opts = array(
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => 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) {
|
||||
returnServerError('Failed to submit captcha response back to Facebook');
|
||||
|
@ -120,15 +118,7 @@ class FacebookBridge extends BridgeAbstract {
|
|||
|
||||
//Retrieve page contents
|
||||
if(is_null($html)) {
|
||||
$http_options = array(
|
||||
'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);
|
||||
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||
|
||||
// First character cannot be a forward slash
|
||||
if(strpos($this->getInput('u'), "/") === 0) {
|
||||
|
@ -136,14 +126,10 @@ class FacebookBridge extends BridgeAbstract {
|
|||
}
|
||||
|
||||
if(!strpos($this->getInput('u'), "/")) {
|
||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1',
|
||||
false,
|
||||
$context)
|
||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', $header)
|
||||
or returnServerError('No results for this query.');
|
||||
} else {
|
||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1',
|
||||
false,
|
||||
$context)
|
||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
||||
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');
|
||||
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => "GET",
|
||||
'user_agent' => ini_get('user_agent'),
|
||||
'accept_encoding' => 'gzip',
|
||||
'header' => "Accept-language: en\r\n
|
||||
Cookie: remixlang=3\r\n"
|
||||
)
|
||||
);
|
||||
$header = array("Accept-language: en\r\nCookie: remixlang=3\r\n");
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
return getContents($this->getURI(), false, $context);
|
||||
return getContents($this->getURI(), $header);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -141,8 +141,8 @@ class YoutubeBridge extends BridgeAbstract {
|
|||
private function ytGetSimpleHTMLDOM($url){
|
||||
return getSimpleHTMLDOM($url,
|
||||
$use_include_path = false,
|
||||
$context = null,
|
||||
$offset = 0,
|
||||
$header = array(),
|
||||
$opts = array(),
|
||||
$maxLen = null,
|
||||
$lowercase = true,
|
||||
$forceTagsClosed = true,
|
||||
|
|
Loading…
Reference in a new issue