def _parse(self, data):
        """
        Parse the response from Facebook's Graph API.

        :param data: A string describing the Graph API's response.
        """
        if type(data) == type(bytes()):
            try:
                data = data.decode('utf-8')
            except UnicodeDecodeError:
                return data

        try:
            data = json.loads(data, parse_float=Decimal)
        except ValueError:
            return data

        # Facebook's Graph API sometimes responds with 'true' or 'false'. Facebook offers no documentation
        # as to the prerequisites for this type of response, though it seems that it responds with 'true'
        # when objects are successfully deleted and 'false' upon attempting to delete or access an item that
        # one does not have access to.
        #
        # For example, the API would respond with 'false' upon attempting to query a feed item without having
        # the 'read_stream' extended permission. If you were to query the entire feed, however, it would respond
        # with an empty list instead.
        #
        # Genius.
        #
        # We'll handle this discrepancy as gracefully as we can by implementing logic to deal with this behavior
        # in the high-level access functions (get, post, delete etc.).
        if type(data) is dict:
            if 'error' in data:
                error = data['error']

                if error.get('type') == "OAuthException":
                    exception = OAuthError
                else:
                    exception = FacebookError

                raise exception(**self._get_error_params(data))

            # Facebook occasionally reports errors in its legacy error format.
            if 'error_msg' in data:
                raise FacebookError(**self._get_error_params(data))

        return data
def _parse ( self , data ) : if type ( data ) == type ( bytes ( ) ) : try : data = data . decode ( 'utf-8' ) except UnicodeDecodeError : return data try : data = json . loads ( data , parse_float = Decimal ) except ValueError : return data if type ( data ) is dict : if 'error' in data : error = data [ 'error' ] if error . get ( 'type' ) == "OAuthException" : exception = OAuthError else : exception = FacebookError raise exception ( ** self . _get_error_params ( data ) ) if 'error_msg' in data : raise FacebookError ( ** self . _get_error_params ( data ) ) return data
Parse the response from Facebook's Graph API.

        :param data: A string describing the Graph API's response.