Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World for Threads #309

Open
scripting opened this issue Jun 19, 2024 · 0 comments
Open

Hello World for Threads #309

scripting opened this issue Jun 19, 2024 · 0 comments

Comments

@scripting
Copy link
Owner

I asked ChatGPT to write a simple Hello World app for the Threads API.

const axios = require('axios');

// Replace with your API token
const apiToken = 'YOUR_API_TOKEN_HERE';

const postHelloWorld = async () => {
    try {
        const response = await axios.post('https://api.threads.com/v1/posts', {
            content: 'Hello, World!'
        }, {
            headers: {
                'Authorization': `Bearer ${apiToken}`,
                'Content-Type': 'application/json'
            }
        });

        console.log('Post ID:', response.data.id);
        console.log('Post Content:', response.data.content);
    } catch (error) {
        console.error('Error posting to Threads API:', error);
    }
};

postHelloWorld();

I haven't tried running it yet. But maybe you can spot problems like cpinto did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant