How to use the twitterapi.User.NewFromJsonDict function in TwitterAPI

To help you get started, we’ve selected a few TwitterAPI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github idan / python-twitter / twitterapi.py View on Github external
def CreateFriendship(self, user):
    '''Befriends the user specified in the user parameter as the authenticating user.

    The twitterapi.Api instance must be authenticated.

    Args:
      The ID or screen name of the user to befriend.
    Returns:
      A twitterapi.User instance representing the befriended user.
    '''
    url = 'http://twitter.com/friendships/create/%s.json' % user
    json = self._FetchUrl(url, post_data={})
    data = simplejson.loads(json)
    return User.NewFromJsonDict(data)
github idan / python-twitter / twitterapi.py View on Github external
def GetUser(self, user):
    '''Returns a single user.

    The twitterapi.Api instance must be authenticated.

    Args:
      user: The username or id of the user to retrieve.

    Returns:
      A twitterapi.User instance representing that user
    '''
    url = 'http://twitter.com/users/show/%s.json' % user
    json = self._FetchUrl(url)
    data = simplejson.loads(json)
    return User.NewFromJsonDict(data)
github idan / python-twitter / twitterapi.py View on Github external
not specified, defaults to the authenticated user. [optional]

    The twitterapi.Api instance must be authenticated.

    Returns:
      A sequence of twitterapi.User instances, one for each friend
    '''
    if not self._username:
      raise TwitterError("twitterapi.Api instance must be authenticated")
    if user:
      url = 'http://twitter.com/statuses/friends/%s.json' % user
    else:
      url = 'http://twitter.com/statuses/friends.json'
    json = self._FetchUrl(url)
    data = simplejson.loads(json)
    return [User.NewFromJsonDict(x) for x in data]
github idan / python-twitter / twitterapi.py View on Github external
def DestroyFriendship(self, user):
    '''Discontinues friendship with the user specified in the user parameter.

    The twitterapi.Api instance must be authenticated.

    Args:
      The ID or screen name of the user  with whom to discontinue friendship.
    Returns:
      A twitterapi.User instance representing the discontinued friend.
    '''
    url = 'http://twitter.com/friendships/destroy/%s.json' % user
    json = self._FetchUrl(url, post_data={})
    data = simplejson.loads(json)
    return User.NewFromJsonDict(data)
github idan / python-twitter / twitterapi.py View on Github external
def GetFeatured(self):
    '''Fetch the sequence of twitterapi.User instances featured on twitter.com

    The twitterapi.Api instance must be authenticated.

    Returns:
      A sequence of twitterapi.User instances
    '''
    url = 'http://twitter.com/statuses/featured.json'
    json = self._FetchUrl(url)
    data = simplejson.loads(json)
    return [User.NewFromJsonDict(x) for x in data]
github idan / python-twitter / twitterapi.py View on Github external
def GetFollowers(self):
    '''Fetch the sequence of twitterapi.User instances, one for each follower

    The twitterapi.Api instance must be authenticated.

    Returns:
      A sequence of twitterapi.User instances, one for each follower
    '''
    if not self._username:
      raise TwitterError("twitterapi.Api instance must be authenticated")
    url = 'http://twitter.com/statuses/followers.json'
    json = self._FetchUrl(url)
    data = simplejson.loads(json)
    return [User.NewFromJsonDict(x) for x in data]