@@ -31,6 +31,8 @@ class FacebookApiException extends Exception
31
31
{
32
32
/**
33
33
* The result from the API server that represents the exception information.
34
+ *
35
+ * @var mixed
34
36
*/
35
37
protected $ result ;
36
38
@@ -132,6 +134,8 @@ abstract class BaseFacebook
132
134
133
135
/**
134
136
* Default options for curl.
137
+ *
138
+ * @var array
135
139
*/
136
140
public static $ CURL_OPTS = array (
137
141
CURLOPT_CONNECTTIMEOUT => 10 ,
@@ -143,6 +147,8 @@ abstract class BaseFacebook
143
147
/**
144
148
* List of query parameters that get automatically dropped when rebuilding
145
149
* the current URL.
150
+ *
151
+ * @var array
146
152
*/
147
153
protected static $ DROP_QUERY_PARAMS = array (
148
154
'code ' ,
@@ -152,6 +158,8 @@ abstract class BaseFacebook
152
158
153
159
/**
154
160
* Maps aliases to Facebook domains.
161
+ *
162
+ * @var array
155
163
*/
156
164
public static $ DOMAIN_MAP = array (
157
165
'api ' => 'https://api.facebook.com/ ' ,
@@ -185,11 +193,15 @@ abstract class BaseFacebook
185
193
186
194
/**
187
195
* The data from the signed_request token.
196
+ *
197
+ * @var string
188
198
*/
189
199
protected $ signedRequest ;
190
200
191
201
/**
192
202
* A CSRF state variable to assist in the defense against CSRF attacks.
203
+ *
204
+ * @var string
193
205
*/
194
206
protected $ state ;
195
207
@@ -258,6 +270,7 @@ public function __construct($config) {
258
270
* Set the Application ID.
259
271
*
260
272
* @param string $appId The Application ID
273
+ *
261
274
* @return BaseFacebook
262
275
*/
263
276
public function setAppId ($ appId ) {
@@ -278,8 +291,10 @@ public function getAppId() {
278
291
* Set the App Secret.
279
292
*
280
293
* @param string $apiSecret The App Secret
294
+ *
281
295
* @return BaseFacebook
282
296
* @deprecated Use setAppSecret instead.
297
+ * @see setAppSecret()
283
298
*/
284
299
public function setApiSecret ($ apiSecret ) {
285
300
$ this ->setAppSecret ($ apiSecret );
@@ -290,6 +305,7 @@ public function setApiSecret($apiSecret) {
290
305
* Set the App Secret.
291
306
*
292
307
* @param string $appSecret The App Secret
308
+ *
293
309
* @return BaseFacebook
294
310
*/
295
311
public function setAppSecret ($ appSecret ) {
@@ -301,7 +317,9 @@ public function setAppSecret($appSecret) {
301
317
* Get the App Secret.
302
318
*
303
319
* @return string the App Secret
320
+ *
304
321
* @deprecated Use getAppSecret instead.
322
+ * @see getAppSecret()
305
323
*/
306
324
public function getApiSecret () {
307
325
return $ this ->getAppSecret ();
@@ -320,6 +338,7 @@ public function getAppSecret() {
320
338
* Set the file upload support status.
321
339
*
322
340
* @param boolean $fileUploadSupport The file upload support status.
341
+ *
323
342
* @return BaseFacebook
324
343
*/
325
344
public function setFileUploadSupport ($ fileUploadSupport ) {
@@ -340,7 +359,9 @@ public function getFileUploadSupport() {
340
359
* Get the file upload support status.
341
360
*
342
361
* @return boolean true if and only if the server supports file upload.
362
+ *
343
363
* @deprecated Use getFileUploadSupport instead.
364
+ * @see getFileUploadSupport()
344
365
*/
345
366
public function useFileUploadSupport () {
346
367
return $ this ->getFileUploadSupport ();
@@ -352,6 +373,7 @@ public function useFileUploadSupport() {
352
373
* to use it.
353
374
*
354
375
* @param string $access_token an access token.
376
+ *
355
377
* @return BaseFacebook
356
378
*/
357
379
public function setAccessToken ($ access_token ) {
@@ -680,7 +702,7 @@ protected function getSignedRequestCookieName() {
680
702
}
681
703
682
704
/**
683
- * Constructs and returns the name of the coookie that potentially contain
705
+ * Constructs and returns the name of the cookie that potentially contain
684
706
* metadata. The cookie is not set by the BaseFacebook class, but it may be
685
707
* set by the JavaScript SDK.
686
708
*
@@ -768,6 +790,8 @@ protected function establishCSRFTokenState() {
768
790
* either logged in to Facebook or has granted an offline access permission.
769
791
*
770
792
* @param string $code An authorization code.
793
+ * @param string $redirect_uri Optional redirect URI. Default null
794
+ *
771
795
* @return mixed An access token exchanged for the authorization code, or
772
796
* false if an access token could not be generated.
773
797
*/
@@ -1022,6 +1046,7 @@ protected function makeRequest($url, $params, $ch=null) {
1022
1046
* Parses a signed_request and validates the signature.
1023
1047
*
1024
1048
* @param string $signed_request A signed token
1049
+ *
1025
1050
* @return array The payload inside it or null if the sig is wrong
1026
1051
*/
1027
1052
protected function parseSignedRequest ($ signed_request ) {
@@ -1062,7 +1087,8 @@ protected function parseSignedRequest($signed_request) {
1062
1087
/**
1063
1088
* Makes a signed_request blob using the given data.
1064
1089
*
1065
- * @param array The data array.
1090
+ * @param array $data The data array.
1091
+ *
1066
1092
* @return string The signed request.
1067
1093
*/
1068
1094
protected function makeSignedRequest ($ data ) {
@@ -1082,7 +1108,8 @@ protected function makeSignedRequest($data) {
1082
1108
/**
1083
1109
* Build the URL for api given parameters.
1084
1110
*
1085
- * @param $method String the method name.
1111
+ * @param string $method The method name.
1112
+ *
1086
1113
* @return string The URL for the given parameters
1087
1114
*/
1088
1115
protected function getApiUrl ($ method ) {
@@ -1159,9 +1186,9 @@ protected function getApiUrl($method) {
1159
1186
/**
1160
1187
* Build the URL for given domain alias, path and parameters.
1161
1188
*
1162
- * @param $name string The name of the domain
1163
- * @param $path string Optional path (without a leading slash)
1164
- * @param $params array Optional query parameters
1189
+ * @param string $name The name of the domain
1190
+ * @param string $path Optional path (without a leading slash)
1191
+ * @param array $params Optional query parameters
1165
1192
*
1166
1193
* @return string The URL for the given parameters
1167
1194
*/
@@ -1180,6 +1207,11 @@ protected function getUrl($name, $path='', $params=array()) {
1180
1207
return $ url ;
1181
1208
}
1182
1209
1210
+ /**
1211
+ * Returns the HTTP Host
1212
+ *
1213
+ * @return string The HTTP Host
1214
+ */
1183
1215
protected function getHttpHost () {
1184
1216
if ($ this ->trustForwarded && isset ($ _SERVER ['HTTP_X_FORWARDED_HOST ' ])) {
1185
1217
$ forwardProxies = explode (', ' , $ _SERVER ['HTTP_X_FORWARDED_HOST ' ]);
@@ -1190,6 +1222,11 @@ protected function getHttpHost() {
1190
1222
return $ _SERVER ['HTTP_HOST ' ];
1191
1223
}
1192
1224
1225
+ /**
1226
+ * Returns the HTTP Protocol
1227
+ *
1228
+ * @return string The HTTP Protocol
1229
+ */
1193
1230
protected function getHttpProtocol () {
1194
1231
if ($ this ->trustForwarded && isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ])) {
1195
1232
if ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ] === 'https ' ) {
@@ -1211,7 +1248,9 @@ protected function getHttpProtocol() {
1211
1248
}
1212
1249
1213
1250
/**
1214
- * Get the base domain used for the cookie.
1251
+ * Returns the base domain used for the cookie.
1252
+ *
1253
+ * @return string The base domain
1215
1254
*/
1216
1255
protected function getBaseDomain () {
1217
1256
// The base domain is stored in the metadata cookie if not we fallback
@@ -1270,7 +1309,7 @@ protected function getCurrentUrl() {
1270
1309
* params that should be stripped out.
1271
1310
*
1272
1311
* @param string $param A key or key/value pair within a URL's query (e.g.
1273
- * 'foo=a', 'foo=', or 'foo'.
1312
+ * 'foo=a', 'foo=', or 'foo'.
1274
1313
*
1275
1314
* @return boolean
1276
1315
*/
@@ -1290,7 +1329,7 @@ protected function shouldRetainParam($param) {
1290
1329
* because the access token is no longer valid. If that is
1291
1330
* the case, then we destroy the session.
1292
1331
*
1293
- * @param $result array A record storing the error message returned
1332
+ * @param array $result A record storing the error message returned
1294
1333
* by a failed API call.
1295
1334
*/
1296
1335
protected function throwAPIException ($ result ) {
@@ -1339,8 +1378,9 @@ protected static function errorLog($msg) {
1339
1378
* _ instead of /
1340
1379
* No padded =
1341
1380
*
1342
- * @param string $input base64UrlEncoded string
1343
- * @return string
1381
+ * @param string $input base64UrlEncoded input
1382
+ *
1383
+ * @return string The decoded string
1344
1384
*/
1345
1385
protected static function base64UrlDecode ($ input ) {
1346
1386
return base64_decode (strtr ($ input , '-_ ' , '+/ ' ));
@@ -1352,8 +1392,8 @@ protected static function base64UrlDecode($input) {
1352
1392
* - instead of +
1353
1393
* _ instead of /
1354
1394
*
1355
- * @param string $input string
1356
- * @return string base64Url encoded string
1395
+ * @param string $input The input to encode
1396
+ * @return string The base64Url encoded input, as a string.
1357
1397
*/
1358
1398
protected static function base64UrlEncode ($ input ) {
1359
1399
$ str = strtr (base64_encode ($ input ), '+/ ' , '-_ ' );
@@ -1393,7 +1433,7 @@ public function destroySession() {
1393
1433
/**
1394
1434
* Parses the metadata cookie that our Javascript API set
1395
1435
*
1396
- * @return an array mapping key to value
1436
+ * @return array an array mapping key to value
1397
1437
*/
1398
1438
protected function getMetadataCookie () {
1399
1439
$ cookie_name = $ this ->getMetadataCookieName ();
@@ -1421,13 +1461,29 @@ protected function getMetadataCookie() {
1421
1461
return $ metadata ;
1422
1462
}
1423
1463
1464
+ /**
1465
+ * Finds whether the given domain is allowed or not
1466
+ *
1467
+ * @param string $big The value to be checked against $small
1468
+ * @param string $small The input string
1469
+ *
1470
+ * @return boolean Returns TRUE if $big matches $small
1471
+ */
1424
1472
protected static function isAllowedDomain ($ big , $ small ) {
1425
1473
if ($ big === $ small ) {
1426
1474
return true ;
1427
1475
}
1428
1476
return self ::endsWith ($ big , '. ' .$ small );
1429
1477
}
1430
1478
1479
+ /**
1480
+ * Checks if $big string ends with $small string
1481
+ *
1482
+ * @param string $big The value to be checked against $small
1483
+ * @param string $small The input string
1484
+ *
1485
+ * @return boolean TRUE if $big ends with $small
1486
+ */
1431
1487
protected static function endsWith ($ big , $ small ) {
1432
1488
$ len = strlen ($ small );
1433
1489
if ($ len === 0 ) {
@@ -1471,6 +1527,7 @@ abstract protected function getPersistentData($key, $default = false);
1471
1527
* Clear the data with $key from the persistent storage
1472
1528
*
1473
1529
* @param string $key
1530
+ *
1474
1531
* @return void
1475
1532
*/
1476
1533
abstract protected function clearPersistentData ($ key );
0 commit comments