Vai al contenuto principale

Crea post utilizzando titoli/sottotitoli personalizzati

In questo esempio vedremo come creare post usando i tuoi contenuti. Puoi fornire contenuti per titoli e sottotitoli per ogni pagina della creatività. Puoi anche inviare contenuti per punti elenco se stai generando un post elenco.

Se si passa il parametro headlines, l'IA non genererà contenuti per headlines/subtitles ecc. e utilizzerà i headlines forniti così come sono. Il numero massimo di caratteri consentiti per titolo e sottotitolo è 200 caratteri

import requests, json

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": "single_image",
"headlines": json.dumps([{"h1": "Heading for first page", "h2": "Subheading for first page", "cta": "Call to action for first page"}, {"h1": "Heading for second page/first listicle bullet point", "h2": "subheading for second page"}, {"h1": "Heading for third page/second listicle bullet point", "h2": "subheading for third page"}]),
"model_version": "2", # Headlines 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))

Se ottieni un file inProgress status in risposta, la tua richiesta ha avuto esito positivo e i post vengono generati. Una volta che i post vengono generati con successo (o falliscono), riceverai una richiesta sull'URL del webhook configurato con maggiori dettagli sui post. In caso di più post, riceverai l'evento webhook per ciascun post separatamente.