mirror of
https://github.com/timberjoegithub/GoogleScrape.git
synced 2026-07-22 00:19:48 +00:00
working tiktok
This commit is contained in:
@@ -1043,6 +1043,22 @@ def post_to_threads2(title, content, headers, date, rating, address, picslist, l
|
|||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
|
||||||
|
def tiktok_upload_video(session_id, file_path, title, tags, schedule_time=None):
|
||||||
|
url = 'https://www.tiktok.com/api/upload/video/'
|
||||||
|
headers = {
|
||||||
|
'Cookie': f'sessionid={session_id}'
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
'title': title,
|
||||||
|
'tags': ','.join(tags),
|
||||||
|
'schedule_time': schedule_time
|
||||||
|
}
|
||||||
|
files = {
|
||||||
|
'video': open(file_path, 'rb')
|
||||||
|
}
|
||||||
|
response = requests.post(url, headers=headers, data=data, files=files)
|
||||||
|
return response.json()
|
||||||
|
|
||||||
def post_to_tiktok(title, content, headers, date, rating, address, picslist, local_outputs):
|
def post_to_tiktok(title, content, headers, date, rating, address, picslist, local_outputs):
|
||||||
"""
|
"""
|
||||||
Posts content to TikTok with specified session ID, video file, title, hashtags, and optional
|
Posts content to TikTok with specified session ID, video file, title, hashtags, and optional
|
||||||
@@ -1062,7 +1078,7 @@ def post_to_tiktok(title, content, headers, date, rating, address, picslist, loc
|
|||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
# Replace 'your_sessionid_cookie' with your actual TikTok sessionid cookie.
|
# Replace 'your_sessionid_cookie' with your actual TikTok sessionid cookie.
|
||||||
session_id = 'your_sessionid_cookie'
|
session_id = env.tiktok_client_secret
|
||||||
|
|
||||||
# Replace 'path_to_video.mp4' with the path to your video file.
|
# Replace 'path_to_video.mp4' with the path to your video file.
|
||||||
file_path = 'path_to_video.mp4'
|
file_path = 'path_to_video.mp4'
|
||||||
@@ -1077,28 +1093,29 @@ def post_to_tiktok(title, content, headers, date, rating, address, picslist, loc
|
|||||||
# Leave it as None if you want to upload immediately.
|
# Leave it as None if you want to upload immediately.
|
||||||
schedule_time = None # or Unix timestamp (e.g., 1672592400)
|
schedule_time = None # or Unix timestamp (e.g., 1672592400)
|
||||||
|
|
||||||
|
"""
|
||||||
|
client_key string The unique identification key provisioned to the partner.
|
||||||
|
client_secret string The unique identification secret provisioned to the partner.
|
||||||
|
code string The authorization code from the web, iOS, Android or desktop authorization callback. The value should be URL decoded.
|
||||||
|
grant_type string Its value should always be set as authorization_code.
|
||||||
|
redirect_uri string Its value must be the same as the redirect_uri used for requesting code.
|
||||||
|
curl --location --request POST 'https://open.tiktokapis.com/v2/oauth/token/' \
|
||||||
|
--header 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
|
--header 'Cache-Control: no-cache' \
|
||||||
|
--data-urlencode 'client_key=CLIENT_KEY' \
|
||||||
|
--data-urlencode 'client_secret=CLIENT_SECRET' \
|
||||||
|
--data-urlencode 'code=CODE' \
|
||||||
|
--data-urlencode 'grant_type=authorization_code' \
|
||||||
|
--data-urlencode 'redirect_uri=REDIRECT_URI'
|
||||||
|
"""
|
||||||
|
header = ['Content-Type: application/x-www-form-urlencoded','Cache-Control: no-cache']
|
||||||
|
data = ['client_key='+env.tiktok_client_key,'client_secret='+env.tiktok_client_secret,'code=CODE','grant_type=authorization_code','redirect_uri=REDIRECT_URI']
|
||||||
|
response = requests.post('https://open.tiktokapis.com/v2/oauth/token/', headers=headers, data=data)
|
||||||
|
|
||||||
|
# Call the function to upload the video
|
||||||
|
response = tiktok_upload_video(session_id, file_path, title, tags, schedule_time)
|
||||||
|
print(response)
|
||||||
return
|
return
|
||||||
|
|
||||||
# def upload_video(session_id, file_path, title, tags, schedule_time=None):
|
|
||||||
# url = 'https://www.tiktok.com/api/upload/video/'
|
|
||||||
# headers = {
|
|
||||||
# 'Cookie': f'sessionid={session_id}'
|
|
||||||
# }
|
|
||||||
# data = {
|
|
||||||
# 'title': title,
|
|
||||||
# 'tags': ','.join(tags),
|
|
||||||
# 'schedule_time': schedule_time
|
|
||||||
# }
|
|
||||||
# files = {
|
|
||||||
# 'video': open(file_path, 'rb')
|
|
||||||
# }
|
|
||||||
# response = requests.post(url, headers=headers, data=data, files=files)
|
|
||||||
# return response.json()
|
|
||||||
|
|
||||||
# # Call the function to upload the video
|
|
||||||
# response = upload_video(session_id, file_path, title, tags, schedule_time)
|
|
||||||
# print(response)
|
|
||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
|
||||||
def post_to_instagram2(title, content, headers, date, rating, address, picslist, local_outputs):
|
def post_to_instagram2(title, content, headers, date, rating, address, picslist, local_outputs):
|
||||||
|
|||||||
Reference in New Issue
Block a user