예제 #1
0
    def get_post_params(self, **kwargs):

        images = kwargs.get('images')
        text = kwargs.get('text')
        content = self.__post(images=images, text=text)
        data, endpoint = helper.get_request_data(content, get_endpoint=True)

        return (data, endpoint)
예제 #2
0
    def post_image_to_facebook(self, response, text):

        if response.status_code == 200:
            data, endpoint = helper.get_request_data(response.content,
                                                     get_endpoint=True)
            data['xc_message'] = text
            data['view_post'] = 'Post'
            payload = MPEncoder(data, boundary=self.uuid)
            return self.__post(data=payload, endpoint=endpoint)
예제 #3
0
파일: comments.py 프로젝트: Scr44gr/sfybook
    def __comment(self, **kwargs) -> bytes:

        text = kwargs.get('text', '')
        data, endpoint = helper.get_request_data(self.make_request(self.comment_url),
                                                 get_endpoint=True)

        data['comment_text'] = text

        response = self.session.post(urls.origin_url()+endpoint, data=data)

        if response.status_code == 200:
            return response.content
예제 #4
0
파일: auth.py 프로젝트: Scr44gr/sfybook
    def __login(self, **kwargs):
        email = kwargs.get('email')
        password = kwargs.get('password')

        # Get first session data.
        response = self.session.get(urls.login_url())

        if response.status_code == 200:
            content = response.content
            data = helper.get_request_data(content)

        # Sign in process.

        data['email'] = email
        data['pass'] = password
        data['login'] = '******'  # or Submit
        response = self.session.post(urls.login_url(), data=data)
        return self.status(response)
예제 #5
0
    def __post(self, **kwargs) -> bytes:

        data = kwargs.get('data')
        endpoint = kwargs.get('endpoint')

        if data is None:
            data, endpoint = helper.get_request_data(self.make_request(
                self.url_id),
                                                     get_endpoint=True)
        if not isinstance(data, MPEncoder):

            image = kwargs.get('images')
            text = kwargs.get('text', '')
            if image:
                data['view_photo'] = 'Photo'
            else:
                data['view_post'] = 'Post'
            data['xc_message'] = text
        else:
            self.set_content_type(data)

        response = self.session.post(urls.origin_url() + endpoint, data=data)
        if response.status_code == 200:
            return response.content