Skip to content

Commit c33c8ac

Browse files
committed
Now provide own server-side HTTP mechanics
1 parent 68bf8a9 commit c33c8ac

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Facebook.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function int_callback(){
6363

6464
if (!empty($results) && !empty($results['access_token'])){
6565
$me = $this->me($results['access_token']);
66-
66+
6767
$this->auth = array(
6868
'provider' => 'Facebook',
6969
'uid' => $me->id,
@@ -129,4 +129,26 @@ private function me($access_token){
129129
return json_decode($me);
130130
}
131131
}
132+
133+
/**
134+
* Simple server-side HTTP request with file_get_contents
135+
* Reluctant to use any more advanced transport like cURL for the time being
136+
* to not having to set cURL as being a requirement.
137+
*
138+
* @param $url string Full URL to load
139+
* @param $options array Stream context options (http://php.net/stream-context-create)
140+
* @param $responseHeaders string Response headers after HTTP call. Useful for error debugging.
141+
* @return string Content resulted from request, without headers
142+
*/
143+
private static function httpRequest($url, $options = null, &$responseHeaders = null){
144+
$context = null;
145+
if (!empty($options) && is_array($options)){
146+
$context = stream_context_create($options);
147+
}
148+
149+
$content = @file_get_contents($url, false, $context);
150+
$responseHeaders = implode("\r\n", $http_response_header);
151+
152+
return $content;
153+
}
132154
}

0 commit comments

Comments
 (0)