INNER CODE UNIT · Python
v1
trevorhobenshield/twitter-api-client · twitter/account.py:69
def v1(self, path: str, params: dict) -> dict:
headers = get_headers(self.session)
headers['content-type'] = 'application/x-www-form-urlencoded'
r = self.session.post(f'{self.v1_api}/{path}', headers=headers, data=urlencode(params))
if self.debug:
log(self.logger, self.debug, r)
return r.json()
def create_poll(self, text: str, choices: list[str], poll_duration: int) -> dict:
options = {
"twitter:card": "poll4choice_text_only",
"twitter:api:api:endpoint": "1",
"twitter:long:duration_minutes": poll_duration # max: 10080
}
for i, c in enumerate(choices):
options[f"twitter:string:choice{i + 1}_label"] = c
headers = get_headers(self.session)