Beispiel #1
0
    def get_access_token(self, code=None):
        """
        After user has authorized the request token, get access token
        with user supplied cod3.
        """
        try:
            url = self._get_oauth_url('access_token')

            parameters = {
                'client_id': self._consumer.key,
                'client_secret': self._consumer.secret,
                'grant_type': 'authorization_code',
                'redirect_uri': self.callback,
                'code': code
            }

            request = oauth.OAuthRequest('POST', url, parameters)
            resp = urlopen(Request(url, data=request.to_postdata()))
            data = resp.read()

            r = import_simplejson().loads(str(data))

            self.access_token = r['access_token']

            return self.access_token
        except Exception, e:
            raise WeibopError(e)
Beispiel #2
0
    def get_access_token(self, code=None):
        """
        After user has authorized the request token, get access token
        with user supplied cod3.
        """
        try:
            url = self._get_oauth_url('access_token')

            parameters = {
                'client_id': self._consumer.key,
                'client_secret': self._consumer.secret,
                'grant_type': 'authorization_code',
                'redirect_uri': self.callback,
                'code': code
                }

            request = oauth.OAuthRequest('POST', url, parameters)
            resp = urlopen(Request(url, data=request.to_postdata()))
            data = resp.read()
            
            r = import_simplejson().loads(str(data))

            self.access_token = r['access_token']
            
            return self.access_token
        except Exception, e:
            raise WeibopError(e)
Beispiel #3
0
 def __init__(self):
     self.json_lib = import_simplejson()
Beispiel #4
0
 def __init__(self):
     self.json_lib = import_simplejson()
Beispiel #5
0
# Copyright 2009-2010 Joshua Roesslein
# See LICENSE for details.

import httplib
from socket import timeout
from threading import Thread
from time import sleep
import urllib

from weibopy.auth import BasicAuthHandler
from weibopy.models import Status
from weibopy.api import API
from weibopy.error import WeibopError

from weibopy.utils import import_simplejson
json = import_simplejson()

STREAM_VERSION = 1


class StreamListener(object):

    def __init__(self, api=None):
        self.api = api or API()

    def on_data(self, data):
        """Called when raw data is received from connection.

        Override this method if you wish to manually handle
        the stream data. Return False to stop stream and close connection.
        """
Beispiel #6
0
# Copyright 2009-2010 Joshua Roesslein
# See LICENSE for details.

import httplib
from socket import timeout
from threading import Thread
from time import sleep
import urllib

from weibopy.auth import BasicAuthHandler
from weibopy.models import Status
from weibopy.api import API
from weibopy.error import WeibopError

from weibopy.utils import import_simplejson
json = import_simplejson()

STREAM_VERSION = 1


class StreamListener(object):

    def __init__(self, api=None):
        self.api = api or API()

    def on_data(self, data):
        """Called when raw data is received from connection.

        Override this method if you wish to manually handle
        the stream data. Return False to stop stream and close connection.
        """