[FacebookBridge] Add requester languages to HTTP header
If no accepted languages are specified Facebook will guess your language. This guess can go horribly wrong if your server does not provide origin information. This adds a context header with language information when retrieving page contents. The accepted languages are read from the list of accepted languages specified by the web browser of the requester. References #530
This commit is contained in:
parent
f38db4d79e
commit
8ed4812e00
1 changed files with 14 additions and 2 deletions
|
@ -111,11 +111,23 @@ 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);
|
||||
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',
|
||||
false,
|
||||
$context)
|
||||
or returnServerError('No results for this query.');
|
||||
} else {
|
||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1')
|
||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1',
|
||||
false,
|
||||
$context)
|
||||
or returnServerError('No results for this query.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue