Ṣẹda Awọn ifiweranṣẹ ni Olopobobo
Ninu apẹẹrẹ yii a yoo wo bii o ṣe le ṣẹda awọn ifiweranṣẹ lọpọlọpọ ni ibeere ẹyọkan nipa lilo Predis.ai API. A yoo kọja awọn n_posts paramita si 3 lati se ina 3 posts ni kan nikan ìbéèrè. O tun le kọja ọpọ template_ids ti o ba fẹ awọn ifiweranṣẹ wọnyi ni awọn apẹrẹ / awọn awoṣe pato.
Ti o ba ti awọn ipari ti template_ids ati n_posts ko baramu, ki o si kere ti awọn mejeeji yoo wa ni lo lati se ina ọpọ posts.
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))
Ti o ba gba a inProgress ipo ni idahun, ibeere rẹ ṣaṣeyọri ati pe awọn ifiweranṣẹ ti wa ni ipilẹṣẹ. Ni kete ti awọn ifiweranṣẹ ba ni ipilẹṣẹ ni aṣeyọri (tabi kuna), iwọ yoo gba ibeere kan lori URL URL ti o tunto rẹ pẹlu awọn alaye diẹ sii nipa awọn ifiweranṣẹ naa. Ninu ọran ti awọn ifiweranṣẹ pupọ, iwọ yoo gba iṣẹlẹ wẹẹbu fun ifiweranṣẹ kọọkan lọtọ.