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)
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)
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
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)
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