request.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:TumblrVideos 作者: moedje 项目源码 文件源码
def post(self, url, params={}, files=[]):
        """
        Issues a POST request against the API, allows for multipart data uploads

        :param url: a string, the url you are requesting
        :param params: a dict, the key-value of all the parameters needed
                       in the request
        :param files: a list, the list of tuples of files

        :returns: a dict parsed of the JSON response
        """
        url = self.host + url
        try:
            if files:
                return self.post_multipart(url, params, files)
            else:
                client = oauth.Client(self.consumer, self.token, proxy_info=self.proxy_info)
                client.disable_ssl_certificate_validation = True
                resp, content = client.request(url, method="POST", body=urllib.urlencode(params))
                return self.json_parse(content)
        except urllib2.HTTPError, e:
            return self.json_parse(e.read())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号