@@ -36,202 +36,202 @@ discard block |
||
| 36 | 36 | class FacebookRequest |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @const string Version number of the Facebook PHP SDK. |
|
| 41 | - */ |
|
| 42 | - const VERSION = '4.0.15'; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @const string Default Graph API version for requests |
|
| 46 | - */ |
|
| 47 | - const GRAPH_API_VERSION = 'v2.2'; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @const string Graph API URL |
|
| 51 | - */ |
|
| 52 | - const BASE_GRAPH_URL = 'https://graph.facebook.com'; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var FacebookSession The session used for this request |
|
| 56 | - */ |
|
| 57 | - private $session; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var string The HTTP method for the request |
|
| 61 | - */ |
|
| 62 | - private $method; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @var string The path for the request |
|
| 66 | - */ |
|
| 67 | - private $path; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @var array The parameters for the request |
|
| 71 | - */ |
|
| 72 | - private $params; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @var string The Graph API version for the request |
|
| 76 | - */ |
|
| 77 | - private $version; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @var string ETag sent with the request |
|
| 81 | - */ |
|
| 82 | - private $etag; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @var FacebookHttpable HTTP client handler |
|
| 86 | - */ |
|
| 87 | - private static $httpClientHandler; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @var int The number of calls that have been made to Graph. |
|
| 91 | - */ |
|
| 92 | - public static $requestCount = 0; |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * getSession - Returns the associated FacebookSession. |
|
| 96 | - * |
|
| 97 | - * @return FacebookSession |
|
| 98 | - */ |
|
| 99 | - public function getSession() |
|
| 100 | - { |
|
| 39 | + /** |
|
| 40 | + * @const string Version number of the Facebook PHP SDK. |
|
| 41 | + */ |
|
| 42 | + const VERSION = '4.0.15'; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @const string Default Graph API version for requests |
|
| 46 | + */ |
|
| 47 | + const GRAPH_API_VERSION = 'v2.2'; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @const string Graph API URL |
|
| 51 | + */ |
|
| 52 | + const BASE_GRAPH_URL = 'https://graph.facebook.com'; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var FacebookSession The session used for this request |
|
| 56 | + */ |
|
| 57 | + private $session; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var string The HTTP method for the request |
|
| 61 | + */ |
|
| 62 | + private $method; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @var string The path for the request |
|
| 66 | + */ |
|
| 67 | + private $path; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @var array The parameters for the request |
|
| 71 | + */ |
|
| 72 | + private $params; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @var string The Graph API version for the request |
|
| 76 | + */ |
|
| 77 | + private $version; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @var string ETag sent with the request |
|
| 81 | + */ |
|
| 82 | + private $etag; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @var FacebookHttpable HTTP client handler |
|
| 86 | + */ |
|
| 87 | + private static $httpClientHandler; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @var int The number of calls that have been made to Graph. |
|
| 91 | + */ |
|
| 92 | + public static $requestCount = 0; |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * getSession - Returns the associated FacebookSession. |
|
| 96 | + * |
|
| 97 | + * @return FacebookSession |
|
| 98 | + */ |
|
| 99 | + public function getSession() |
|
| 100 | + { |
|
| 101 | 101 | return $this->session; |
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * getPath - Returns the associated path. |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function getPath() |
|
| 110 | - { |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * getPath - Returns the associated path. |
|
| 106 | + * |
|
| 107 | + * @return string |
|
| 108 | + */ |
|
| 109 | + public function getPath() |
|
| 110 | + { |
|
| 111 | 111 | return $this->path; |
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * getParameters - Returns the associated parameters. |
|
| 116 | - * |
|
| 117 | - * @return array |
|
| 118 | - */ |
|
| 119 | - public function getParameters() |
|
| 120 | - { |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * getParameters - Returns the associated parameters. |
|
| 116 | + * |
|
| 117 | + * @return array |
|
| 118 | + */ |
|
| 119 | + public function getParameters() |
|
| 120 | + { |
|
| 121 | 121 | return $this->params; |
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * getMethod - Returns the associated method. |
|
| 126 | - * |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function getMethod() |
|
| 130 | - { |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * getMethod - Returns the associated method. |
|
| 126 | + * |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function getMethod() |
|
| 130 | + { |
|
| 131 | 131 | return $this->method; |
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * getETag - Returns the ETag sent with the request. |
|
| 136 | - * |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - public function getETag() |
|
| 140 | - { |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * getETag - Returns the ETag sent with the request. |
|
| 136 | + * |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + public function getETag() |
|
| 140 | + { |
|
| 141 | 141 | return $this->etag; |
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * setHttpClientHandler - Returns an instance of the HTTP client |
|
| 146 | - * handler |
|
| 147 | - * |
|
| 148 | - * @param \Facebook\HttpClients\FacebookHttpable |
|
| 149 | - */ |
|
| 150 | - public static function setHttpClientHandler(FacebookHttpable $handler) |
|
| 151 | - { |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * setHttpClientHandler - Returns an instance of the HTTP client |
|
| 146 | + * handler |
|
| 147 | + * |
|
| 148 | + * @param \Facebook\HttpClients\FacebookHttpable |
|
| 149 | + */ |
|
| 150 | + public static function setHttpClientHandler(FacebookHttpable $handler) |
|
| 151 | + { |
|
| 152 | 152 | static::$httpClientHandler = $handler; |
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * getHttpClientHandler - Returns an instance of the HTTP client |
|
| 157 | - * data handler |
|
| 158 | - * |
|
| 159 | - * @return FacebookHttpable |
|
| 160 | - */ |
|
| 161 | - public static function getHttpClientHandler() |
|
| 162 | - { |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * getHttpClientHandler - Returns an instance of the HTTP client |
|
| 157 | + * data handler |
|
| 158 | + * |
|
| 159 | + * @return FacebookHttpable |
|
| 160 | + */ |
|
| 161 | + public static function getHttpClientHandler() |
|
| 162 | + { |
|
| 163 | 163 | if (static::$httpClientHandler) { |
| 164 | - return static::$httpClientHandler; |
|
| 164 | + return static::$httpClientHandler; |
|
| 165 | 165 | } |
| 166 | 166 | return function_exists('curl_init') ? new FacebookCurlHttpClient() : new FacebookStreamHttpClient(); |
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * FacebookRequest - Returns a new request using the given session. optional |
|
| 171 | - * parameters hash will be sent with the request. This object is |
|
| 172 | - * immutable. |
|
| 173 | - * |
|
| 174 | - * @param FacebookSession $session |
|
| 175 | - * @param string $method |
|
| 176 | - * @param string $path |
|
| 177 | - * @param array|null $parameters |
|
| 178 | - * @param string|null $version |
|
| 179 | - * @param string|null $etag |
|
| 180 | - */ |
|
| 181 | - public function __construct( |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * FacebookRequest - Returns a new request using the given session. optional |
|
| 171 | + * parameters hash will be sent with the request. This object is |
|
| 172 | + * immutable. |
|
| 173 | + * |
|
| 174 | + * @param FacebookSession $session |
|
| 175 | + * @param string $method |
|
| 176 | + * @param string $path |
|
| 177 | + * @param array|null $parameters |
|
| 178 | + * @param string|null $version |
|
| 179 | + * @param string|null $etag |
|
| 180 | + */ |
|
| 181 | + public function __construct( |
|
| 182 | 182 | FacebookSession $session, $method, $path, $parameters = null, $version = null, $etag = null |
| 183 | - ) |
|
| 184 | - { |
|
| 183 | + ) |
|
| 184 | + { |
|
| 185 | 185 | $this->session = $session; |
| 186 | 186 | $this->method = $method; |
| 187 | 187 | $this->path = $path; |
| 188 | 188 | if ($version) { |
| 189 | - $this->version = $version; |
|
| 189 | + $this->version = $version; |
|
| 190 | 190 | } else { |
| 191 | - $this->version = static::GRAPH_API_VERSION; |
|
| 191 | + $this->version = static::GRAPH_API_VERSION; |
|
| 192 | 192 | } |
| 193 | 193 | $this->etag = $etag; |
| 194 | 194 | |
| 195 | 195 | $params = ($parameters ?: array()); |
| 196 | 196 | if ($session |
| 197 | 197 | && !isset($params["access_token"])) { |
| 198 | - $params["access_token"] = $session->getToken(); |
|
| 198 | + $params["access_token"] = $session->getToken(); |
|
| 199 | 199 | } |
| 200 | 200 | if (FacebookSession::useAppSecretProof() |
| 201 | 201 | && !isset($params["appsecret_proof"])) { |
| 202 | - $params["appsecret_proof"] = $this->getAppSecretProof( |
|
| 202 | + $params["appsecret_proof"] = $this->getAppSecretProof( |
|
| 203 | 203 | $params["access_token"] |
| 204 | - ); |
|
| 204 | + ); |
|
| 205 | 205 | } |
| 206 | 206 | $this->params = $params; |
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Returns the base Graph URL. |
|
| 211 | - * |
|
| 212 | - * @return string |
|
| 213 | - */ |
|
| 214 | - protected function getRequestURL() |
|
| 215 | - { |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Returns the base Graph URL. |
|
| 211 | + * |
|
| 212 | + * @return string |
|
| 213 | + */ |
|
| 214 | + protected function getRequestURL() |
|
| 215 | + { |
|
| 216 | 216 | return static::BASE_GRAPH_URL . '/' . $this->version . $this->path; |
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * execute - Makes the request to Facebook and returns the result. |
|
| 221 | - * |
|
| 222 | - * @return FacebookResponse |
|
| 223 | - * |
|
| 224 | - * @throws FacebookSDKException |
|
| 225 | - * @throws FacebookRequestException |
|
| 226 | - */ |
|
| 227 | - public function execute() |
|
| 228 | - { |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * execute - Makes the request to Facebook and returns the result. |
|
| 221 | + * |
|
| 222 | + * @return FacebookResponse |
|
| 223 | + * |
|
| 224 | + * @throws FacebookSDKException |
|
| 225 | + * @throws FacebookRequestException |
|
| 226 | + */ |
|
| 227 | + public function execute() |
|
| 228 | + { |
|
| 229 | 229 | $url = $this->getRequestURL(); |
| 230 | 230 | $params = $this->getParameters(); |
| 231 | 231 | |
| 232 | 232 | if ($this->method === "GET") { |
| 233 | - $url = self::appendParamsToUrl($url, $params); |
|
| 234 | - $params = array(); |
|
| 233 | + $url = self::appendParamsToUrl($url, $params); |
|
| 234 | + $params = array(); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $connection = self::getHttpClientHandler(); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | // ETag |
| 242 | 242 | if (isset($this->etag)) { |
| 243 | - $connection->addRequestHeader('If-None-Match', $this->etag); |
|
| 243 | + $connection->addRequestHeader('If-None-Match', $this->etag); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Should throw `FacebookSDKException` exception on HTTP client error. |
@@ -256,49 +256,49 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | $decodedResult = json_decode($result); |
| 258 | 258 | if ($decodedResult === null) { |
| 259 | - $out = array(); |
|
| 260 | - parse_str($result, $out); |
|
| 261 | - return new FacebookResponse($this, $out, $result, $etagHit, $etagReceived); |
|
| 259 | + $out = array(); |
|
| 260 | + parse_str($result, $out); |
|
| 261 | + return new FacebookResponse($this, $out, $result, $etagHit, $etagReceived); |
|
| 262 | 262 | } |
| 263 | 263 | if (isset($decodedResult->error)) { |
| 264 | - throw FacebookRequestException::create( |
|
| 264 | + throw FacebookRequestException::create( |
|
| 265 | 265 | $result, |
| 266 | 266 | $decodedResult->error, |
| 267 | 267 | $connection->getResponseHttpStatusCode() |
| 268 | - ); |
|
| 268 | + ); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | return new FacebookResponse($this, $decodedResult, $result, $etagHit, $etagReceived); |
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Generate and return the appsecret_proof value for an access_token |
|
| 276 | - * |
|
| 277 | - * @param string $token |
|
| 278 | - * |
|
| 279 | - * @return string |
|
| 280 | - */ |
|
| 281 | - public function getAppSecretProof($token) |
|
| 282 | - { |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Generate and return the appsecret_proof value for an access_token |
|
| 276 | + * |
|
| 277 | + * @param string $token |
|
| 278 | + * |
|
| 279 | + * @return string |
|
| 280 | + */ |
|
| 281 | + public function getAppSecretProof($token) |
|
| 282 | + { |
|
| 283 | 283 | return hash_hmac('sha256', $token, FacebookSession::_getTargetAppSecret()); |
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * appendParamsToUrl - Gracefully appends params to the URL. |
|
| 288 | - * |
|
| 289 | - * @param string $url |
|
| 290 | - * @param array $params |
|
| 291 | - * |
|
| 292 | - * @return string |
|
| 293 | - */ |
|
| 294 | - public static function appendParamsToUrl($url, $params = array()) |
|
| 295 | - { |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * appendParamsToUrl - Gracefully appends params to the URL. |
|
| 288 | + * |
|
| 289 | + * @param string $url |
|
| 290 | + * @param array $params |
|
| 291 | + * |
|
| 292 | + * @return string |
|
| 293 | + */ |
|
| 294 | + public static function appendParamsToUrl($url, $params = array()) |
|
| 295 | + { |
|
| 296 | 296 | if (!$params) { |
| 297 | - return $url; |
|
| 297 | + return $url; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (strpos($url, '?') === false) { |
| 301 | - return $url . '?' . http_build_query($params, null, '&'); |
|
| 301 | + return $url . '?' . http_build_query($params, null, '&'); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | list($path, $query_string) = explode('?', $url, 2); |
@@ -308,6 +308,6 @@ discard block |
||
| 308 | 308 | $params = array_merge($params, $query_array); |
| 309 | 309 | |
| 310 | 310 | return $path . '?' . http_build_query($params, null, '&'); |
| 311 | - } |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | protected function getRequestURL() |
| 215 | 215 | { |
| 216 | - return static::BASE_GRAPH_URL . '/' . $this->version . $this->path; |
|
| 216 | + return static::BASE_GRAPH_URL.'/'.$this->version.$this->path; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $connection = self::getHttpClientHandler(); |
| 238 | - $connection->addRequestHeader('User-Agent', 'fb-php-' . self::VERSION); |
|
| 238 | + $connection->addRequestHeader('User-Agent', 'fb-php-'.self::VERSION); |
|
| 239 | 239 | $connection->addRequestHeader('Accept-Encoding', '*'); // Support all available encodings. |
| 240 | 240 | |
| 241 | 241 | // ETag |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (strpos($url, '?') === false) { |
| 301 | - return $url . '?' . http_build_query($params, null, '&'); |
|
| 301 | + return $url.'?'.http_build_query($params, null, '&'); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | list($path, $query_string) = explode('?', $url, 2); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // Favor params from the original URL over $params |
| 308 | 308 | $params = array_merge($params, $query_array); |
| 309 | 309 | |
| 310 | - return $path . '?' . http_build_query($params, null, '&'); |
|
| 310 | + return $path.'?'.http_build_query($params, null, '&'); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | } |
@@ -32,104 +32,104 @@ |
||
| 32 | 32 | class GraphUser extends GraphObject |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Returns the ID for the user as a string if present. |
|
| 37 | - * |
|
| 38 | - * @return string|null |
|
| 39 | - */ |
|
| 40 | - public function getId() |
|
| 41 | - { |
|
| 35 | + /** |
|
| 36 | + * Returns the ID for the user as a string if present. |
|
| 37 | + * |
|
| 38 | + * @return string|null |
|
| 39 | + */ |
|
| 40 | + public function getId() |
|
| 41 | + { |
|
| 42 | 42 | return $this->getProperty('id'); |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Returns the name for the user as a string if present. |
|
| 47 | - * |
|
| 48 | - * @return string|null |
|
| 49 | - */ |
|
| 50 | - public function getName() |
|
| 51 | - { |
|
| 45 | + /** |
|
| 46 | + * Returns the name for the user as a string if present. |
|
| 47 | + * |
|
| 48 | + * @return string|null |
|
| 49 | + */ |
|
| 50 | + public function getName() |
|
| 51 | + { |
|
| 52 | 52 | return $this->getProperty('name'); |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function getEmail() |
|
| 56 | - { |
|
| 55 | + public function getEmail() |
|
| 56 | + { |
|
| 57 | 57 | return $this->getProperty('email'); |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Returns the first name for the user as a string if present. |
|
| 62 | - * |
|
| 63 | - * @return string|null |
|
| 64 | - */ |
|
| 65 | - public function getFirstName() |
|
| 66 | - { |
|
| 60 | + /** |
|
| 61 | + * Returns the first name for the user as a string if present. |
|
| 62 | + * |
|
| 63 | + * @return string|null |
|
| 64 | + */ |
|
| 65 | + public function getFirstName() |
|
| 66 | + { |
|
| 67 | 67 | return $this->getProperty('first_name'); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Returns the middle name for the user as a string if present. |
|
| 72 | - * |
|
| 73 | - * @return string|null |
|
| 74 | - */ |
|
| 75 | - public function getMiddleName() |
|
| 76 | - { |
|
| 70 | + /** |
|
| 71 | + * Returns the middle name for the user as a string if present. |
|
| 72 | + * |
|
| 73 | + * @return string|null |
|
| 74 | + */ |
|
| 75 | + public function getMiddleName() |
|
| 76 | + { |
|
| 77 | 77 | return $this->getProperty('middle_name'); |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Returns the last name for the user as a string if present. |
|
| 82 | - * |
|
| 83 | - * @return string|null |
|
| 84 | - */ |
|
| 85 | - public function getLastName() |
|
| 86 | - { |
|
| 80 | + /** |
|
| 81 | + * Returns the last name for the user as a string if present. |
|
| 82 | + * |
|
| 83 | + * @return string|null |
|
| 84 | + */ |
|
| 85 | + public function getLastName() |
|
| 86 | + { |
|
| 87 | 87 | return $this->getProperty('last_name'); |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Returns the gender for the user as a string if present. |
|
| 92 | - * |
|
| 93 | - * @return string|null |
|
| 94 | - */ |
|
| 95 | - public function getGender() |
|
| 96 | - { |
|
| 90 | + /** |
|
| 91 | + * Returns the gender for the user as a string if present. |
|
| 92 | + * |
|
| 93 | + * @return string|null |
|
| 94 | + */ |
|
| 95 | + public function getGender() |
|
| 96 | + { |
|
| 97 | 97 | return $this->getProperty('gender'); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Returns the Facebook URL for the user as a string if available. |
|
| 102 | - * |
|
| 103 | - * @return string|null |
|
| 104 | - */ |
|
| 105 | - public function getLink() |
|
| 106 | - { |
|
| 100 | + /** |
|
| 101 | + * Returns the Facebook URL for the user as a string if available. |
|
| 102 | + * |
|
| 103 | + * @return string|null |
|
| 104 | + */ |
|
| 105 | + public function getLink() |
|
| 106 | + { |
|
| 107 | 107 | return $this->getProperty('link'); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Returns the users birthday, if available. |
|
| 112 | - * |
|
| 113 | - * @return \DateTime|null |
|
| 114 | - */ |
|
| 115 | - public function getBirthday() |
|
| 116 | - { |
|
| 110 | + /** |
|
| 111 | + * Returns the users birthday, if available. |
|
| 112 | + * |
|
| 113 | + * @return \DateTime|null |
|
| 114 | + */ |
|
| 115 | + public function getBirthday() |
|
| 116 | + { |
|
| 117 | 117 | $value = $this->getProperty('birthday'); |
| 118 | 118 | if ($value) { |
| 119 | - return new \DateTime($value); |
|
| 119 | + return new \DateTime($value); |
|
| 120 | 120 | } |
| 121 | 121 | return null; |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Returns the current location of the user as a FacebookGraphLocation |
|
| 126 | - * if available. |
|
| 127 | - * |
|
| 128 | - * @return GraphLocation|null |
|
| 129 | - */ |
|
| 130 | - public function getLocation() |
|
| 131 | - { |
|
| 124 | + /** |
|
| 125 | + * Returns the current location of the user as a FacebookGraphLocation |
|
| 126 | + * if available. |
|
| 127 | + * |
|
| 128 | + * @return GraphLocation|null |
|
| 129 | + */ |
|
| 130 | + public function getLocation() |
|
| 131 | + { |
|
| 132 | 132 | return $this->getProperty('location', GraphLocation::className()); |
| 133 | - } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | if (version_compare(PHP_VERSION, '5.4.0', '<')) { |
| 32 | - throw new Exception('The Facebook SDK v4 requires PHP version 5.4 or higher.'); |
|
| 32 | + throw new Exception('The Facebook SDK v4 requires PHP version 5.4 or higher.'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -42,29 +42,29 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | spl_autoload_register(function ($class) |
| 44 | 44 | { |
| 45 | - // project-specific namespace prefix |
|
| 46 | - $prefix = 'Facebook\\'; |
|
| 45 | + // project-specific namespace prefix |
|
| 46 | + $prefix = 'Facebook\\'; |
|
| 47 | 47 | |
| 48 | - // base directory for the namespace prefix |
|
| 49 | - $base_dir = defined('FACEBOOK_SDK_V4_SRC_DIR') ? FACEBOOK_SDK_V4_SRC_DIR : __DIR__ . '/src/Facebook/'; |
|
| 48 | + // base directory for the namespace prefix |
|
| 49 | + $base_dir = defined('FACEBOOK_SDK_V4_SRC_DIR') ? FACEBOOK_SDK_V4_SRC_DIR : __DIR__ . '/src/Facebook/'; |
|
| 50 | 50 | |
| 51 | - // does the class use the namespace prefix? |
|
| 52 | - $len = strlen($prefix); |
|
| 53 | - if (strncmp($prefix, $class, $len) !== 0) { |
|
| 51 | + // does the class use the namespace prefix? |
|
| 52 | + $len = strlen($prefix); |
|
| 53 | + if (strncmp($prefix, $class, $len) !== 0) { |
|
| 54 | 54 | // no, move to the next registered autoloader |
| 55 | 55 | return; |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - // get the relative class name |
|
| 59 | - $relative_class = substr($class, $len); |
|
| 58 | + // get the relative class name |
|
| 59 | + $relative_class = substr($class, $len); |
|
| 60 | 60 | |
| 61 | - // replace the namespace prefix with the base directory, replace namespace |
|
| 62 | - // separators with directory separators in the relative class name, append |
|
| 63 | - // with .php |
|
| 64 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 61 | + // replace the namespace prefix with the base directory, replace namespace |
|
| 62 | + // separators with directory separators in the relative class name, append |
|
| 63 | + // with .php |
|
| 64 | + $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 65 | 65 | |
| 66 | - // if the file exists, require it |
|
| 67 | - if (file_exists($file)) { |
|
| 66 | + // if the file exists, require it |
|
| 67 | + if (file_exists($file)) { |
|
| 68 | 68 | require $file; |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | }); |
| 71 | 71 | \ No newline at end of file |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | * @param string $class The fully-qualified class name. |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | -spl_autoload_register(function ($class) |
|
| 43 | +spl_autoload_register(function($class) |
|
| 44 | 44 | { |
| 45 | 45 | // project-specific namespace prefix |
| 46 | 46 | $prefix = 'Facebook\\'; |
| 47 | 47 | |
| 48 | 48 | // base directory for the namespace prefix |
| 49 | - $base_dir = defined('FACEBOOK_SDK_V4_SRC_DIR') ? FACEBOOK_SDK_V4_SRC_DIR : __DIR__ . '/src/Facebook/'; |
|
| 49 | + $base_dir = defined('FACEBOOK_SDK_V4_SRC_DIR') ? FACEBOOK_SDK_V4_SRC_DIR : __DIR__.'/src/Facebook/'; |
|
| 50 | 50 | |
| 51 | 51 | // does the class use the namespace prefix? |
| 52 | 52 | $len = strlen($prefix); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | // replace the namespace prefix with the base directory, replace namespace |
| 62 | 62 | // separators with directory separators in the relative class name, append |
| 63 | 63 | // with .php |
| 64 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 64 | + $file = $base_dir.str_replace('\\', '/', $relative_class).'.php'; |
|
| 65 | 65 | |
| 66 | 66 | // if the file exists, require it |
| 67 | 67 | if (file_exists($file)) { |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | * Please edit the facebook.conf.php file to adapt it to your fb application parameter |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -require_once dirname(__FILE__) . '/../../inc/global.inc.php'; |
|
| 15 | -require_once dirname(__FILE__) . '/facebook.init.php'; |
|
| 16 | -require_once dirname(__FILE__) . '/facebook-php-sdk/autoload.php'; |
|
| 14 | +require_once dirname(__FILE__).'/../../inc/global.inc.php'; |
|
| 15 | +require_once dirname(__FILE__).'/facebook.init.php'; |
|
| 16 | +require_once dirname(__FILE__).'/facebook-php-sdk/autoload.php'; |
|
| 17 | 17 | |
| 18 | 18 | use Facebook\FacebookSession; |
| 19 | 19 | use Facebook\FacebookRedirectLoginHelper; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | use Facebook\HttpClients\FacebookCurlHttpClient; |
| 28 | 28 | use Facebook\HttpClients\FacebookHttpable; |
| 29 | 29 | |
| 30 | -require_once dirname(__FILE__) . '/functions.inc.php'; |
|
| 30 | +require_once dirname(__FILE__).'/functions.inc.php'; |
|
| 31 | 31 | |
| 32 | 32 | // dont rename $facebook_config to $facebookConfig otherwise get a "Facebook\\FacebookSDKException" |
| 33 | 33 | FacebookSession::setDefaultApplication($facebook_config['appId'], $facebook_config['secret']); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $locale = $graphObject->getProperty('locale'); |
| 58 | 58 | $language = facebookPluginGetLanguage($locale); |
| 59 | 59 | if (!$language) { |
| 60 | - $language='en_US'; |
|
| 60 | + $language = 'en_US'; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | //Checks if user already exists in chamilo |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $_user['user_id'] = $chamilo_uid; |
| 86 | 86 | $_user['uidReset'] = true; |
| 87 | 87 | $_SESSION['_user'] = $_user; |
| 88 | - header('Location:' . api_get_path(WEB_PATH)); |
|
| 88 | + header('Location:'.api_get_path(WEB_PATH)); |
|
| 89 | 89 | exit(); |
| 90 | 90 | } else { |
| 91 | 91 | return false; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $_user['user_id'] = $chamilo_uid; |
| 99 | 99 | $_user['uidReset'] = true; |
| 100 | 100 | $_SESSION['_user'] = $_user; |
| 101 | - header('Location:' . api_get_path(WEB_PATH)); |
|
| 101 | + header('Location:'.api_get_path(WEB_PATH)); |
|
| 102 | 102 | exit(); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | global $facebook_config; |
| 119 | 119 | $helper = new FacebookRedirectLoginHelper($facebook_config['return_url']); |
| 120 | - $loginUrl = $helper->getLoginUrl( |
|
| 120 | + $loginUrl = $helper->getLoginUrl( |
|
| 121 | 121 | array('scope' => 'email') |
| 122 | 122 | ); |
| 123 | 123 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $wsUrl = ''; |
| 15 | 15 | |
| 16 | 16 | // include common authentication functions |
| 17 | -require_once dirname(__FILE__) . '/functions.inc.php'; |
|
| 17 | +require_once dirname(__FILE__).'/functions.inc.php'; |
|
| 18 | 18 | // call the login checker (defined below) |
| 19 | 19 | $isValid = loginWSAuthenticate($login, $password, $wsUrl); |
| 20 | 20 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | $key = '-+*%$({[]})$%*+-'; |
| 62 | 62 | // Complete password con PKCS7-specific padding |
| 63 | 63 | $blockSize = 16; |
| 64 | - $padding = $blockSize - (strlen($password)%$blockSize); |
|
| 65 | - $password .= str_repeat(chr($padding),$padding); |
|
| 64 | + $padding = $blockSize - (strlen($password) % $blockSize); |
|
| 65 | + $password .= str_repeat(chr($padding), $padding); |
|
| 66 | 66 | $cipher = new Crypt_AES(CRYPT_AES_MODE_CFB); |
| 67 | 67 | $cipher->setKeyLength(128); |
| 68 | 68 | $cipher->setKey($key); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | use ChamiloSession as Session; |
| 9 | 9 | |
| 10 | -require_once(dirname(__FILE__) . '/functions.inc.php'); |
|
| 10 | +require_once(dirname(__FILE__).'/functions.inc.php'); |
|
| 11 | 11 | |
| 12 | 12 | //MAIN CODE |
| 13 | 13 | //$uData variable is set in local.inc.php |
@@ -36,6 +36,6 @@ discard block |
||
| 36 | 36 | //User cannot login |
| 37 | 37 | $loginFailed = true; |
| 38 | 38 | Session::erase('_uid'); |
| 39 | - header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=user_password_incorrect'); |
|
| 39 | + header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=user_password_incorrect'); |
|
| 40 | 40 | exit; |
| 41 | 41 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | use ChamiloSession as Session; |
| 12 | 12 | |
| 13 | -require_once(dirname(__FILE__) . '/functions.inc.php'); |
|
| 13 | +require_once(dirname(__FILE__).'/functions.inc.php'); |
|
| 14 | 14 | |
| 15 | 15 | //MAIN CODE |
| 16 | 16 | //$login and $password variables are setted in main/inc/local.inc.php |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | } |
| 14 | 14 | use \ChamiloSession as Session; |
| 15 | 15 | |
| 16 | -require dirname(__FILE__) . '/../../inc/global.inc.php'; |
|
| 17 | -require dirname(__FILE__) . '/ldap.inc.php'; |
|
| 18 | -require dirname(__FILE__) . '/../../inc/conf/auth.conf.php'; |
|
| 16 | +require dirname(__FILE__).'/../../inc/global.inc.php'; |
|
| 17 | +require dirname(__FILE__).'/ldap.inc.php'; |
|
| 18 | +require dirname(__FILE__).'/../../inc/conf/auth.conf.php'; |
|
| 19 | 19 | /** |
| 20 | 20 | * Code execution |
| 21 | 21 | */ |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | |
| 40 | 40 | use ChamiloSession as Session; |
| 41 | 41 | |
| 42 | -require_once dirname(__FILE__) . '/ldap.inc.php'; |
|
| 43 | -require_once dirname(__FILE__) . '/functions.inc.php'; |
|
| 42 | +require_once dirname(__FILE__).'/ldap.inc.php'; |
|
| 43 | +require_once dirname(__FILE__).'/functions.inc.php'; |
|
| 44 | 44 | |
| 45 | 45 | $ldap_user = extldap_authenticate($login, $password); |
| 46 | 46 | if ($ldap_user !== false) { |