示例#1
0
文件: forrst.py 项目: durden/frappy
    def __init__(self, req_format="json", domain="forrst.com/api",
                 secure=False, auth=None, api_version='v2'):

        domain += "/%s" % (api_version)

        APICall.__init__(self, auth=auth, req_format=req_format, domain=domain,
                         secure=secure)
示例#2
0
文件: twitter.py 项目: durden/frappy
    def __init__(self, req_format="json", domain="api.twitter.com", secure=True, auth=None, api_version="1"):
        """
        Create a new twitter API connector.

        Pass an `auth` parameter to use the credentials of a specific
        user. Generally you'll want to pass an `OAuth`
        instance::

            twitter = Twitter(auth=OAuth(
                    token, token_secret, consumer_key, consumer_secret))


        `domain` lets you change the domain you are connecting. By
        default it's `api.twitter.com` but `search.twitter.com` may be
        useful too.

        If `secure` is False you will connect with HTTP instead of
        HTTPS.

        `api_version` is used to set the base uri. By default it's '1'.
        """
        if req_format not in ("json", "xml", ""):
            raise ValueError("Unknown data format '%s'" % (req_format))

        if api_version is 1:
            if domain == "api.twitter.com" or domain == "stream.twitter.com":
                api_version = "1"
            else:
                api_version = None

        domain += "/%s" % (api_version)

        APICall.__init__(self, auth=auth, req_format=req_format, domain=domain, secure=secure)
示例#3
0
    def __init__(self, username, api_key, domain="codrspace.com/api/"):

        APICall.__init__(self, auth=None, req_format='json', domain=domain,
                         secure=False)

        self._api_key = api_key
        self._username = username
示例#4
0
文件: twitter.py 项目: durden/frappy
    def service_build_uri(self, *args, **kwargs):
        """
        Complete creation of request uri by adding additional Twitter specific
        syntax, etc.
        """

        # Append all extra arguments from *args
        APICall.service_build_uri(self, *args, **kwargs)

        # If an id kwarg is present and there is no id to fill in in
        # the list of uriparts, assume the id goes at the end.
        id = kwargs.pop("id", None)
        if id:
            self.uri += "/%s" % (id)

        # Twitter allows for specifying request format in uri
        dot = ""
        if self.req_format:
            dot = "."

        self.uri += "%s%s" % (dot, self.req_format)

        return kwargs
示例#5
0
文件: github.py 项目: durden/frappy
    def __init__(self, req_format="json", domain="api.github.com",
                 secure=True, auth=None):

        APICall.__init__(self, auth=auth, req_format=req_format, domain=domain,
                         secure=secure)