Sample code

Introduction

This section provides sample code for using the MovieGlu APIs.

  • curl
  • PHP
  • Ajax
  • C#
  • More coming soon.

curl

This is probably the most basic way for you to return data from our API.  It basically allows you to send the request and http headers via a command line.

If you haven’t used curl before, here are a couple of good introductions:

and you can download it from here:

Syntax

curl "https://api-gate2.movieglu.com/filmsComingSoon/?n=1" -H "api-version: [VERSION]" -H "Authorization: [BASIC AUTHENTICATION]" -H "x-api-key: [API-KEY]" -H "device-datetime: [DATE-TIME]" -H "territory: [TERRITORY]" -H "client: [USERNAME]"

Example

Don’t forget to your own credentials – these are just sample credentials.
IMPORTANT: Check device-datetime is current

curl "https://api-gate2.movieglu.com/filmsNowShowing/?n=1" -H "api-version: v200" -H "Authorization: Basic A1B2c3D4E5f6H7I8j911M12=" -H "x-api-key: IyrBUDT7CuTTc6LH45mI5aAoG8" -H "device-datetime: 2018-09-26T10:45:30.147Z" -H "territory: UK" -H "client: ABCD"

PHP

Our PHP sample code can be found in our public github repository:

https://github.com/movieglu/movieglu-code-samples/tree/master/php


Ajax

Don’t forget to replace these credentials with YOURS, in the fields below.

var settings = {
"url": "https://api-gate2.movieglu.com/filmsNowShowing/?n=10",
"method": "GET",
"timeout": 0,
"headers": {
"api-version": "v200",
"Authorization": "Basic A1B2c3D4E5f6H7I8j911M12=",
"client": "ABCD",
"x-api-key": "IyrBUDT7CuTTc6LH45mI5aAoG8",
"device-datetime": "2020-06-18T12:07:57.296Z",
"territory": "UK",
},
};

$.ajax(settings).done(function (response) {
console.log(response);
});

C# – RestSharp

Don’t forget to replace these credentials with YOURS, in the fields below.

var client = new RestClient("https://api-gate2.movieglu.com/filmsNowShowing/?n=5");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("api-version", "v200");
request.AddHeader("Authorization", "Basic A1B2c3D4E5f6H7I8j911M12=");
request.AddHeader("client", "ABCD");
request.AddHeader("x-api-key", "D4E5f6H7I8j911M12A1B2c3D4E5f6H");
request.AddHeader("device-datetime", "2020-06-18T12:07:57.296Z");
request.AddHeader("territory", "UK");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);