// Replace 'YOUR_API_KEY' with your actual API key

const apiKey = 'YOUR_API_KEY';


// Function to make a call using Ziwo API

async function makeCall(toNumber, fromNumber) {

    try {

        const response = await fetch('https://api.ziwo.io/v1/calls', {

            method: 'POST',

            headers: {

                'Content-Type': 'application/json',

                'Authorization': `Bearer ${apiKey}`

            },

            body: JSON.stringify({

                to: toNumber,

                from: fromNumber,

                // Additional parameters can be added here, such as custom caller ID, etc.

            })

        });

        

        if (!response.ok) {

            throw new Error('Failed to make call');

        }

        

        const data = await response.json();

        console.log('Call successfully initiated:', data);

    } catch (error) {

        console.error('Error making call:', error);

    }

}


// Example: Make a call to a phone number

makeCall('+1234567890', '+9876543210');

Comments

Popular posts from this blog

How to seperate character from string in php

How to Delete record using PHP Ajax

Uploads Only 10 files in month step by step