Content Generation and Publishing Bot Documentation

This bot helps you automatically generate and publish content on various social media platforms. With this documentation, you can easily use the bot and connect it to your applications and systems.

Registration and API Key

First, you need to sign up on the platform and obtain an API key. This key is essential for authentication and accessing the bot's services.

Registration Steps:

  1. Visit the platform's website.
  2. Complete the registration form.
  3. After registration, your API key will be provided via email or in your user profile section.

How to Use

1. Generate Content

Endpoint

POST /api/v1/generate_content

Headers

{'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'}

Body Parameters

Parameter Type Description
topic string The topic for which you want to generate content.
format string The format of the content (blog_post, tweet, instagram_post, etc.).
language string The language of the content (optional, default: en).

Sample Request

{'topic': 'Example Topic', 'format': 'blog_post', 'language': 'en'}

Sample Response

{'id': '12345', 'content': 'This is the generated content based on the provided topic and format.', 'status': 'success'}

2. Schedule Post

Endpoint

POST /api/v1/schedule_post

Headers

{'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'}

Body Parameters

Parameter Type Description
content_id string The ID of the generated content.
platform string The platform to publish on (twitter, instagram, etc.).
schedule_time string The scheduled time for publishing in ISO 8601 format (e.g., 2024-06-15T12:00:00Z).

Sample Request

{'content_id': '12345', 'platform': 'twitter', 'schedule_time': '2024-06-15T12:00:00Z'}

Sample Response

{'status': 'success', 'message': 'Post has been scheduled successfully.'}

Connecting to the Bot Using Different Programming Languages

Python

Install Requirements

pip install requests

Sample Code

import requests

API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://api.neutrinobot.com'

def generate_content(topic, format, language='en'):
    url = f"{BASE_URL}/api/v1/generate_content"
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json'
    }
    payload = {
        'topic': topic,
        'format': format,
        'language': language
    }
    response = requests.post(url, json=payload, headers=headers)
    return response.json()

def schedule_post(content_id, platform, schedule_time):
    url = f"{BASE_URL}/api/v1/schedule_post"
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json'
    }
    payload = {
        'content_id': content_id,
        'platform': platform,
        'schedule_time': schedule_time
    }
    response = requests.post(url, json=payload, headers=headers)
    return response.json()

# Example usage
content = generate_content("Example Topic", "blog_post")
print(content)
schedule_response = schedule_post(content['id'], "twitter", "2024-06-15T12:00:00Z")
print(schedule_response)

JavaScript (Node.js)

Install Requirements

npm install axios

Sample Code

const axios = require('axios');

const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://api.neutrinobot.com';

async function generateContent(topic, format, language = 'en') {
    const url = `${BASE_URL}/api/v1/generate_content`;
    const headers = {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
    };
    const payload = {
        topic: topic,
        format: format,
        language: language
    };
    const response = await axios.post(url, payload, { headers: headers });
    return response.data;
}

async function schedulePost(contentId, platform, scheduleTime) {
    const url = `${BASE_URL}/api/v1/schedule_post`;
    const headers = {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
    };
    const payload = {
        content_id: contentId,
        platform: platform,
        schedule_time: scheduleTime
    };
    const response = await axios.post(url, payload, { headers: headers });
    return response.data;
}

// Example usage
generateContent("Example Topic", "blog_post")
    .then(content => {
        console.log(content);
        return schedulePost(content.id, "twitter", "2024-06-15T12:00:00Z");
    })
    .then(scheduleResponse => {
        console.log(scheduleResponse);
    });

PHP

Sample Code

<?php

function generate_content($topic, $format, $api_key, $language = 'en') {
    $url = 'https://api.neutrinobot.com/api/v1/generate_content';
    $headers = [
        'Authorization: Bearer ' . $api_key,
        'Content-Type: application/json'
    ];
    $payload = json_encode([
        'topic' => $topic,
        'format' => $format,
        'language' => $language
    ]);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response, true);
}

function schedule_post($content_id, $platform, $schedule_time, $api_key) {
    $url = 'https://api.neutrinobot.com/api/v1/schedule_post';
    $headers = [
        'Authorization: Bearer ' . $api_key,
        'Content-Type: application/json'
    ];
    $payload = json_encode([
        'content_id' => $content_id,
        'platform' => $platform,
        'schedule_time' => $schedule_time
    ]);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response, true);
}

// Example usage
$api_key = 'YOUR_API_KEY';
$content = generate_content('Example Topic', 'blog_post', $api_key);
print_r($content);
$schedule_response = schedule_post($content['id'], 'twitter', '2024-06-15T12:00:00Z', $api_key);
print_r($schedule_response);
?>

Kotlin

Install Requirements

dependencies {
    implementation("io.ktor:ktor-client-core:2.0.0")
    implementation("io.ktor:ktor-client-cio:2.0.0")
    implementation("io.ktor:ktor-client-json:2.0.0")
    implementation("io.ktor:ktor-client-serialization:2.0.0")
}

Sample Code

import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.features.logging.*
import kotlinx.coroutines.*

const val API_KEY = "YOUR_API_KEY"
const val BASE_URL = "https://api.neutrinobot.com"

suspend fun generateContent(topic: String, format: String, language: String = "en"): String {
    val client = HttpClient {
        install(JsonFeature) {
            serializer = KotlinxSerializer()
        }
        install(Logging) {
            level = LogLevel.BODY
        }
    }

    val response: HttpResponse = client.post("$BASE_URL/api/v1/generate_content") {
        headers {
            append("Authorization", "Bearer $API_KEY")
            append("Content-Type", "application/json")
        }
        body = mapOf(
            "topic" to topic,
            "format" to format,
            "language" to language
        )
    }

    return response.readText()
}

suspend fun schedulePost(contentId: String, platform: String, scheduleTime: String): String {
    val client = HttpClient {
        install(JsonFeature) {
            serializer = KotlinxSerializer()
        }
        install(Logging) {
            level = LogLevel.BODY
        }
    }

    val response: HttpResponse = client.post("$BASE_URL/api/v1/schedule_post") {
        headers {
            append("Authorization", "Bearer $API_KEY")
            append("Content-Type", "application/json")
        }
        body = mapOf(
            "content_id" to contentId,
            "platform" to platform,
            "schedule_time" to scheduleTime
        )
    }

    return response.readText()
}

fun main() = runBlocking {
    val content = generateContent("Example Topic", "blog_post")
    println(content)
    val contentJson = Json.parseToJsonElement(content).jsonObject
    val contentId = contentJson["id"]?.jsonPrimitive?.content ?: throw IllegalStateException("Content ID not found")

    val scheduleResponse = schedulePost(contentId, "twitter", "2024-06-15T12:00:00Z")
    println(scheduleResponse)
}

Java

Install Requirements

<dependency>
    <groupId>org.apache.httpcomponents.client5</groupId>
    <artifactId>httpclient5</artifactId>
    <version>5.1</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.13.0</version>
</dependency>

Sample Code

import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.io.entity.StringEntity;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.io.IOException;

public class NeutrinoBotAPI {
    private static final String API_KEY = "YOUR_API_KEY";
    private static final String BASE_URL = "https://api.neutrinobot.com";

    public static void main(String[] args) throws IOException {
        String content = generateContent("Example Topic", "blog_post");
        System.out.println(content);
        ObjectMapper mapper = new ObjectMapper();
        String contentId = mapper.readTree(content).get("id").asText();
        String scheduleResponse = schedulePost(contentId, "twitter", "2024-06-15T12:00:00Z");
        System.out.println(scheduleResponse);
    }

    public static String generateContent(String topic, String format, String language) throws IOException {
        String url = BASE_URL + "/api/v1/generate_content";
        CloseableHttpClient client = HttpClients.createDefault();
        HttpPost post = new HttpPost(url);

        post.setHeader("Authorization", "Bearer " + API_KEY);
        post.setHeader("Content-Type", "application/json");

        ObjectMapper mapper = new ObjectMapper();
        ObjectNode payload = mapper.createObjectNode();
        payload.put("topic", topic);
        payload.put("format", format);
        payload.put("language", language);

        StringEntity entity = new StringEntity(payload.toString());
        post.setEntity(entity);

        CloseableHttpResponse response = client.execute(post);
        String responseBody = new String(response.getEntity().getContent().readAllBytes());
        client.close();

        return responseBody;
    }

    public static String schedulePost(String contentId, String platform, String scheduleTime) throws IOException {
        String url = BASE_URL + "/api/v1/schedule_post";
        CloseableHttpClient client = HttpClients.createDefault();
        HttpPost post = new HttpPost(url);

        post.setHeader("Authorization", "Bearer " + API_KEY);
        post.setHeader("Content-Type", "application/json");

        ObjectMapper mapper = new ObjectMapper();
        ObjectNode payload = mapper.createObjectNode();
        payload.put("content_id", contentId);
        payload.put("platform", platform);
        payload.put("schedule_time", scheduleTime);

        StringEntity entity = new StringEntity(payload.toString());
        post.setEntity(entity);

        CloseableHttpResponse response = client.execute(post);
        String responseBody = new String(response.getEntity().getContent().readAllBytes());
        client.close();

        return responseBody;
    }
}

Ruby

Install Requirements

gem install httparty

Sample Code

require 'httparty'
require 'json'

API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://api.neutrinobot.com'

def generate_content(topic, format, language='en')
  url = "#{BASE_URL}/api/v1/generate_content"
  headers = {
    'Authorization' => "Bearer #{API_KEY}",
    'Content-Type' => 'application/json'
  }
  payload = {
    topic: topic,
    format: format,
    language: language
  }
  response = HTTParty.post(url, headers: headers, body: payload.to_json)
  JSON.parse(response.body)
end

def schedule_post(content_id, platform, schedule_time)
  url = "#{BASE_URL}/api/v1/schedule_post"
  headers = {
    'Authorization' => "Bearer #{API_KEY}",
    'Content-Type' => 'application/json'
  }
  payload = {
    content_id: content_id,
    platform: platform,
    schedule_time: schedule_time
  }
  response = HTTParty.post(url, headers: headers, body: payload.to_json)
  JSON.parse(response.body)
end

# Example usage
content = generate_content("Example Topic", "blog_post")
puts content
schedule_response = schedule_post(content['id'], "twitter", "2024-06-15T12:00:00Z")
puts schedule_response

C++

Install Requirements

# Ubuntu
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libjsoncpp-dev

Sample Code

#include 
#include 
#include 
#include 

const std::string API_KEY = "YOUR_API_KEY";
const std::string BASE_URL = "https://api.neutrinobot.com";

size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

std::string generateContent(const std::string& topic, const std::string& format, const std::string& language = "en") {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    curl = curl_easy_init();
    if(curl) {
        std::string url = BASE_URL + "/api/v1/generate_content";
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, ("Authorization: Bearer " + API_KEY).c_str());
        headers = curl_slist_append(headers, "Content-Type: application/json");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        Json::Value payload;
        payload["topic"] = topic;
        payload["format"] = format;
        payload["language"] = language;
        Json::StreamWriterBuilder writer;
        std::string requestBody = Json::writeString(writer, payload);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.c_str());

        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    return readBuffer;
}

std::string schedulePost(const std::string& contentId, const std::string& platform, const std::string& scheduleTime) {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    curl = curl_easy_init();
    if(curl) {
        std::string url = BASE_URL + "/api/v1/schedule_post";
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, ("Authorization: Bearer " + API_KEY).c_str());
        headers = curl_slist_append(headers, "Content-Type: application/json");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        Json::Value payload;
        payload["content_id"] = contentId;
        payload["platform"] = platform;
        payload["schedule_time"] = scheduleTime;
        Json::StreamWriterBuilder writer;
        std::string requestBody = Json::writeString(writer, payload);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.c_str());

        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    return readBuffer;
}

int main() {
    std::string content = generateContent("Example Topic", "blog_post");
    std::cout << "Generated Content: " << content << std::endl;

    Json::CharReaderBuilder reader;
    Json::Value contentJson;
    std::string errs;
    std::istringstream s(content);
    std::string contentId;

    if (Json::parseFromStream(reader, s, &contentJson, &errs)) {
        contentId = contentJson["id"].asString();
    } else {
        std::cerr << "Error parsing JSON: " << errs << std::endl;
        return 1;
    }

    std::string scheduleResponse = schedulePost(contentId, "twitter", "2024-06-15T12:00:00Z");
    std::cout << "Schedule Response: " << scheduleResponse << std::endl;

    return 0;
}

Go

Install Requirements

go get -u net/http
go get -u encoding/json

Sample Code

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

const (
    API_KEY  = "YOUR_API_KEY"
    BASE_URL = "https://api.neutrinobot.com"
)

type GenerateContentPayload struct {
    Topic    string `json:"topic"`
    Format   string `json:"format"`
    Language string `json:"language"`
}

type SchedulePostPayload struct {
    ContentID    string `json:"content_id"`
    Platform     string `json:"platform"`
    ScheduleTime string `json:"schedule_time"`
}

func generateContent(topic, format, language string) (string, error) {
    url := BASE_URL + "/api/v1/generate_content"
    payload := GenerateContentPayload{
        Topic:    topic,
        Format:   format,
        Language: language,
    }

    jsonData, err := json.Marshal(payload)
    if err != nil {
        return "", err
    }

    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    if err != nil {
        return "", err
    }
    req.Header.Set("Authorization", "Bearer "+API_KEY)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return "", err
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return "", err
    }

    return string(body), nil
}

func schedulePost(contentID, platform, scheduleTime string) (string, error) {
    url := BASE_URL + "/api/v1/schedule_post"
    payload := SchedulePostPayload{
        ContentID:    contentID,
        Platform:     platform,
        ScheduleTime: scheduleTime,
    }

    jsonData, err := json.Marshal(payload)
    if err != nil {
        return "", err
    }

    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    if err != nil {
        return "", err
    }
    req.Header.Set("Authorization", "Bearer "+API_KEY)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return "", err
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return "", err
    }

    return string(body), nil
}

func main() {
    content, err := generateContent("Example Topic", "blog_post", "en")
    if err != nil {
        fmt.Println("Error generating content:", err)
        return
    }
    fmt.Println("Generated Content:", content)

    var contentJson map[string]interface{}
    if err := json.Unmarshal([]byte(content), &contentJson); err != nil {
        fmt.Println("Error parsing JSON:", err)
        return
    }
    contentID := contentJson["id"].(string)

    scheduleResponse, err := schedulePost(contentID, "twitter", "2024-06-15T12:00:00Z")
    if err != nil {
        fmt.Println("Error scheduling post:", err)
        return
    }
    fmt.Println("Schedule Response:", scheduleResponse)
}

Error Handling

When using the API, you may encounter various errors. Here are some common errors and how to handle them:

Common Errors

Status Code Description Possible Causes
400 Bad Request The request could not be understood or was missing required parameters. Check the request parameters and ensure they are correctly formatted.
401 Unauthorized Authentication failed or user does not have permissions for the requested operation. Ensure the API key is correct and has the necessary permissions.
403 Forbidden Access to the requested resource is denied. The API key does not have the necessary permissions.
404 Not Found The requested resource could not be found. Verify the endpoint URL and resource ID.
500 Internal Server Error An error occurred on the server. Try the request again later. If the problem persists, contact support.

Sample Error Response

{
    "status": "error",
    "message": "Invalid API key",
    "code": 401
}

Handling Errors in Code

Python

import requests

def generate_content(topic, format, api_key, language='en'):
    url = 'https://api.neutrinobot.com/api/v1/generate_content'
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }
    payload = {
        'topic': topic,
        'format': format,
        'language': language
    }
    response = requests.post(url, json=payload, headers=headers)
    if response.status_code != 200:
        raise Exception(f"Error: {response.status_code} - {response.json()['message']}")
    return response.json()

def schedule_post(content_id, platform, schedule_time, api_key):
    url = 'https://api.neutrinobot.com/api/v1/schedule_post'
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }
    payload = {
        'content_id': content_id,
        'platform': platform,
        'schedule_time': schedule_time
    }
    response = requests.post(url, json=payload, headers=headers)
    if response.status_code != 200:
        raise Exception(f"Error: {response.status_code} - {response.json()['message']}")
    return response.json()

# Example usage
try:
    content = generate_content("Example Topic", "blog_post", 'YOUR_API_KEY')
    print(content)
    schedule_response = schedule_post(content['id'], "twitter", "2024-06-15T12:00:00Z", 'YOUR_API_KEY')
    print(schedule_response)
except Exception as e:
    print(e)

JavaScript (Node.js)

const axios = require('axios');

const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://api.neutrinobot.com';

async function generateContent(topic, format, language = 'en') {
    const url = `${BASE_URL}/api/v1/generate_content`;
    const headers = {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
    };
    const payload = {
        topic: topic,
        format: format,
        language: language
    };
    try {
        const response = await axios.post(url, payload, { headers: headers });
        return response.data;
    } catch (error) {
        console.error(`Error: ${error.response.status} - ${error.response.data.message}`);
        throw error;
    }
}

async function schedulePost(contentId, platform, scheduleTime) {
    const url = `${BASE_URL}/api/v1/schedule_post`;
    const headers = {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
    };
    const payload = {
        content_id: contentId,
        platform: platform,
        schedule_time: scheduleTime
    };
    try {
        const response = await axios.post(url, payload, { headers: headers });
        return response.data;
    } catch (error) {
        console.error(`Error: ${error.response.status} - ${error.response.data.message}`);
        throw error;
    }
}

// Example usage
generateContent("Example Topic", "blog_post")
    .then(content => {
        console.log(content);
        return schedulePost(content.id, "twitter", "2024-06-15T12:00:00Z");
    })
    .then(scheduleResponse => {
        console.log(scheduleResponse);
    })
    .catch(error => {
        console.error(error);
    });

PHP

<?php

function generate_content($topic, $format, $api_key, $language = 'en') {
    $url = 'https://api.neutrinobot.com/api/v1/generate_content';
    $headers = [
        'Authorization: Bearer ' . $api_key,
        'Content-Type: application/json'
    ];
    $payload = json_encode([
        'topic' => $topic,
        'format' => $format,
        'language' => $language
    ]);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        throw new Exception('Request Error: ' . curl_error($ch));
    }
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($http_code != 200) {
        $response_data = json_decode($response, true);
        throw new Exception('Error: ' . $http_code . ' - ' . $response_data['message']);
    }

    return json_decode($response, true);
}

function schedule_post($content_id, $platform, $schedule_time, $api_key) {
    $url = 'https://api.neutrinobot.com/api/v1/schedule_post';
    $headers = [
        'Authorization: Bearer ' . $api_key,
        'Content-Type: application/json'
    ];
    $payload = json_encode([
        'content_id' => $content_id,
        'platform' => $platform,
        'schedule_time' => $schedule_time
    ]);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        throw new Exception('Request Error: ' . curl_error($ch));
    }
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($http_code != 200) {
        $response_data = json_decode($response, true);
        throw new Exception('Error: ' . $http_code . ' - ' . $response_data['message']);
    }

    return json_decode($response, true);
}

// Example usage
$api_key = 'YOUR_API_KEY';
try {
    $content = generate_content('Example Topic', 'blog_post', $api_key);
    print_r($content);
    $schedule_response = schedule_post($content['id'], 'twitter', '2024-06-15T12:00:00Z', $api_key);
    print_r($schedule_response);
} catch (Exception $e) {
    echo $e->getMessage();
}
?>