

Nextrek
@ 461
Nextrek / Android / SmartCharging / endPoints / nightly / fb_SDK / src / Facebook / FacebookRequestException.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
<?php /** * Copyright 2014 Facebook, Inc. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to * use, copy, modify, and distribute this software in source code or binary * form for use in connection with the web services and APIs provided by * Facebook. * * As with any software that integrates with the Facebook platform, your use * of this software is subject to the Facebook Developer Principles and * Policies [http://developers.facebook.com/policy/]. This copyright notice * shall be included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ namespace Facebook; /** * Class FacebookRequestException * @package Facebook * @author Fosco Marotto <fjm@fb.com> * @author David Poll <depoll@fb.com> */ class FacebookRequestException extends FacebookSDKException { /** * @var int Status code for the response causing the exception */ private $statusCode; /** * @var string Raw response */ private $rawResponse; /** * @var array Decoded response */ private $responseData; /** * Creates a FacebookRequestException. * * @param string $rawResponse The raw response from the Graph API * @param array $responseData The decoded response from the Graph API * @param int $statusCode */ public function __construct($rawResponse, $responseData, $statusCode) { $this->rawResponse = $rawResponse; $this->statusCode = $statusCode; $this->responseData = self::convertToArray($responseData); parent::__construct( $this->get('message', 'Unknown Exception'), $this->get('code', -1), null ); } /** * Process an error payload from the Graph API and return the appropriate * exception subclass. * * @param string $raw the raw response from the Graph API * @param array $data the decoded response from the Graph API * @param int $statusCode the HTTP response code * * @return FacebookRequestException */ public static function create($raw, $data, $statusCode) { $data = self::convertToArray($data); if (!isset($data['error']['code']) && isset($data['code'])) { $data = array('error' => $data); } $code = (isset($data['error']['code']) ? (int) $data['error']['code'] : null); if (isset($data['error']['error_subcode'])) { switch ($data['error']['error_subcode']) { // Other authentication issues case 458: case 459: case 460: case 463: case 464: case 467: return new FacebookAuthorizationException($raw, $data, $statusCode); break; } } switch ($code) { // Login status or token expired, revoked, or invalid case 100: case 102: case 190: return new FacebookAuthorizationException($raw, $data, $statusCode); break; // Server issue, possible downtime case 1: case 2: return new FacebookServerException($raw, $data, $statusCode); break; // API Throttling case 4: case 17: case 341: return new FacebookThrottleException($raw, $data, $statusCode); break; // Duplicate Post case 506: return new FacebookClientException($raw, $data, $statusCode); break; } // Missing Permissions if ($code === 10 || ($code >= 200 && $code <= 299)) { return new FacebookPermissionException($raw, $data, $statusCode); } // OAuth authentication error if (isset($data['error']['type']) and $data['error']['type'] === 'OAuthException') { return new FacebookAuthorizationException($raw, $data, $statusCode); } // All others return new FacebookOtherException($raw, $data, $statusCode); } /** * Checks isset and returns that or a default value. * * @param string $key * @param mixed $default * * @return mixed */ private function get($key, $default = null) { if (isset($this->responseData['error'][$key])) { return $this->responseData['error'][$key]; } return $default; } /** * Returns the HTTP status code * * @return int */ public function getHttpStatusCode() { return $this->statusCode; } /** * Returns the sub-error code * * @return int */ public function getSubErrorCode() { return $this->get('error_subcode', -1); } /** * Returns the error type * * @return string */ public function getErrorType() { return $this->get('type', ''); } /** * Returns the raw response used to create the exception. * * @return string */ public function getRawResponse() { return $this->rawResponse; } /** * Returns the decoded response used to create the exception. * * @return array */ public function getResponse() { return $this->responseData; } /** * Converts a stdClass object to an array * * @param mixed $object * * @return array */ private static function convertToArray($object) { if ($object instanceof \stdClass) { return get_object_vars($object); } return $object; } } |
Commits for Nextrek/Android/SmartCharging/endPoints/nightly/fb_SDK/src/Facebook/FacebookRequestException.php
Revision | Author | Commited | Message |
---|---|---|---|
461 |
![]() |
Mon 03 Aug, 2015 10:04:56 +0000 | Aggiunto supporto login Facebook, logout utente e modifiche (solo lato repo) all’utente e al locale. |