Example #1
0
    def _request(self, method, uri, kw, file_params):
        raw_qs, qs = QQWeibo.sign(method, uri, self.consumer_key,
                                  self.consumer_secret, self.token_secret,
                                  **kw)
        if method == "GET":
            full_uri = "%s?%s" % (uri, qs)
            resp, content = httplib2_request(full_uri, method)
        else:
            if file_params:
                from past.utils import encode_multipart_data
                body, headers = encode_multipart_data(raw_qs, file_params)
            else:
                body = qs
                headers = None
            resp, content = httplib2_request(uri,
                                             method,
                                             body,
                                             headers=headers)

        log.debug("---qq check result, status: %s, resp: %s, content: %s" %
                  (resp.status, resp, content))
        if resp.status != 200:
            raise OAuthLoginError(msg='get_unauthorized_request_token fail, status=%s:reason=%s:content=%s' \
                    %(resp.status, resp.reason, content))
        return content
Example #2
0
    def post_status_with_image(self, text, image_file):
        from past.utils import encode_multipart_data

        d = {"status": text, "access_token": self.access_token}
        f = {"pic": image_file}
        body, headers = encode_multipart_data(d, f)
        contents = self.post("/statuses/upload.json", body=body, headers=headers)
Example #3
0
    def post_status_with_image(self, text, image_file):
        from past.utils import encode_multipart_data

        d = {"text": text}
        f = {"image": image_file}
        body, headers = encode_multipart_data(d, f)
        contents = self.post("/shuo/statuses/", body=body, headers=headers)
Example #4
0
    def _request(self, method, uri, kw, file_params):
        raw_qs, qs = QQOAuth1Login.sign(method, uri, self.consumer_key,
                                        self.consumer_secret,
                                        self.token_secret, **kw)
        print "+++++ sign:", raw_qs, qs
        if method == "GET":
            full_uri = "%s?%s" % (uri, qs)
            resp, content = httplib2_request(full_uri, method)
        else:
            if file_params:
                from past.utils import encode_multipart_data
                body, headers = encode_multipart_data(raw_qs, file_params)
            else:
                body = qs
                headers = None
            resp, content = httplib2_request(uri,
                                             method,
                                             body,
                                             headers=headers)

        if resp.status != 200:
            raise OAuthLoginError('get_unauthorized_request_token fail, status=%s:reason=%s:content=%s' \
                    %(resp.status, resp.reason, content))
        print "++++++ qq request content:", resp.status, resp.reason, content
        return content
Example #5
0
 def post_status_with_image(self, text, image_file):
     from past.utils import encode_multipart_data
     d = {"status": text, "access_token": self.access_token}
     f = {"pic": image_file}
     body, headers = encode_multipart_data(d, f)
     contents = self.post("/statuses/upload.json",
                          body=body,
                          headers=headers)
Example #6
0
 def _request(self, method, uri, kw, file_params):
     raw_qs, qs = QQWeibo.sign(method, uri, self.consumer_key, 
             self.consumer_secret, self.token_secret, **kw)
     if method == "GET":
         full_uri = "%s?%s" % (uri, qs)
         resp, content = httplib2_request(full_uri, method)
     else:
         if file_params:
             from past.utils import encode_multipart_data
             body, headers = encode_multipart_data(raw_qs, file_params)
         else:
             body = qs
             headers = None
         resp, content = httplib2_request(uri, method, body, headers=headers)
         
     if resp.status != 200:
         raise OAuthLoginError(msg='get_unauthorized_request_token fail, status=%s:reason=%s:content=%s' \
                 %(resp.status, resp.reason, content))
     return content
Example #7
0
 def post_status_with_image(self, text, image_file):
     from past.utils import encode_multipart_data
     d = {"text": text}
     f = {"image": image_file}
     body, headers = encode_multipart_data(d, f)
     return self.post("/shuo/statuses/", body=body, headers=headers)