Skip to content ka sehloohong

Theha Liphatlalatso ka Bongata

Mohlaleng ona re tla sheba mokhoa oa ho theha li-post tse ngata ka kopo e le 'ngoe u sebelisa Predis.ai API. Re tla feta n_posts parameter ho 3 ho hlahisa li-post tse 3 ka kopo e le 'ngoe. U ka boela ua fetisa tse ngata template_ids haeba u batla li-post tsena ka meralo / litempele tse ikhethileng.

Haeba bolelele ba template_ids 'me n_posts ha li tsamaellane, 'me bonyane ba tsona ka bobeli li tla sebelisoa ho hlahisa melaetsa e mengata.

import json
import requests

url = "https://brain.predis.ai/predis_api/v1/create_content/"

payload = {
"brand_id": "YOUR_BRAND_ID",
"text": "3 tips for a healthy morning breakfast",
"media_type": "carousel",
"template_ids": json.dumps(["TEMPLATE_ID_1", "TEMPLATE_ID_2", "TEMPLATE_ID_3"]), # pass template_ids if you want video in specific design
"n_posts": 3, # generate these many posts
"model_version": "2", # template_ids not supported by model_version 4
}

headers = {"Authorization": "YOUR_API_KEY"}

response = requests.request("POST", url, data=payload, headers=headers)

if response.status_code == 200:
json_response = response.json()
post_id = json_response.get("post_id")
post_status = json_response.get("status")

else:
print("Error occurred - {}".format(response.text))

Haeba u fumana file ea inProgress boemo ha u arabela, kopo ea hau e atlehile 'me li-post li ntse li hlahisoa. Hang ha lipehelo li hlahisoa ka katleho (kapa li hloleha), u tla fumana kopo ho URL ea hau ea webhook e nang le lintlha tse ling mabapi le lipapatso. Tabeng ea li-post tse ngata, u tla fumana ketsahalo ea webhook bakeng sa poso ka 'ngoe ka thoko.