Loading

Error Sorry

Cart Total

$0.00

  • Your shopping cart is empty

Checkout

Delete everything ?

VoIP API Code Examples - C# and PHP

VoIP API Code Examples - C# and PHP

|

2 min read

Blog Articles

Quick Summary

Learn how to send requests to the Yay.com API using C# or PHP

The two code snippets below show how to send a basic GET request to the Yay.com API using C# and PHP, the C# snippet has been tested using .NET Core and will work across all supported .NET platforms

C# Example

var dict = new Dictionary<string, string> {
    {"X-Auth-Reseller", "reseller"},
    {"X-Auth-User", "user"},
    {"X-Auth-Password", "password"}
};

var client = new HttpClient {
    BaseAddress = new Uri("https://api.yay.com/authenticated"),
    DefaultRequestHeaders = {
        UserAgent = {
            new ProductInfoHeaderValue("ApiExample", "1.0")
        }
    }
};

foreach (var key in dict.Keys) {
    client.DefaultRequestHeaders.Add(key, dict[key]);
}

var response = client.GetAsync("").Result;
if (!response.IsSuccessStatusCode) return;

var jsonResponse = response.Content.ReadAsStringAsync().Result;

PHP Example

The example below uses the Httpful library for ease of integration

// We use the httpful library for ease
include('httpful.phar');

try {

    $response = \Httpful\Request::get('https://api.yay.com/authenticated')
        ->addHeaders(
            array(
                'X-Auth-Reseller' => 'reseller',
                'X-Auth-User' => 'user',
                'X-Auth-Password' => 'password'
            )
        )
        ->send();

    printf($response->body);

} catch (\Httpful\Exception\ConnectionErrorException $e) {
    printf($e);
}
VoIP API Code Examples - C# and PHP

In this Category

See More
How to Use Our VoIP API to Elevate Your Phone System
How to Use Our VoIP API to Elevate Your Phone System

Use our open VoIP API to create your own features, tweak existing ones or to extract call data not readily available from our dashboard.

Posted December 3 2021 | 4 min

VoIP API Beginners Guide Part 2
VoIP API Beginners Guide Part 2

In this blog post, we'll discuss how to create and segregate customers on your account using our comprehensive VoIP Reseller API.

Posted September 4 2017 | 5 min

VoIP API Beginners Guide Part 1
VoIP API Beginners Guide Part 1

Want to become a VoIP Provider? Use our VoIP API to create SIP accounts and phone numbers

Posted December 16 2016 | 4 min

Article By

Geoff - Senior Analyst Developer at Yay.com

Geoff

Senior Analyst Developer at Yay.com

ISO 27001 Business Continuity Accreditation ISO 22301 Business Continuity Accreditation Cyber Essentials Certificate of Assurance G-Cloud accredited by the Crown Commercial Service
ISO 27001 Business Continuity Accreditation ISO 22301 Business Continuity Accreditation Cyber Essentials Certificate of Assurance G-Cloud accredited by the Crown Commercial Service