Skip to content

Instantly share code, notes, and snippets.

@haltuf
Created August 16, 2022 06:33
Show Gist options
  • Save haltuf/49d2c73db5a25661627433748d5ec475 to your computer and use it in GitHub Desktop.
Save haltuf/49d2c73db5a25661627433748d5ec475 to your computer and use it in GitHub Desktop.
Moodix API - authentication and moodixstat endpoint call
<?php declare(strict_types=1);
/**
* Basic authentication and call of `moodixstat` endpoint
*/
$username = 'test';
$password = 'test';
$url = 'https://app.moodix.market/api/moodixstat/?format=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = [
'Authorization: Basic ' . base64_encode($username . ':' . $password),
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close ($ch);
$json = json_decode($result, true);
var_dump($json);
/**
* array(1) {
* [0] => array(7) {
* 'time' => string(32) "2022-08-15T23:29:46.699443-07:00"
* 'moodix_wave' => string(6) "RiskOn"
* 'risk' => string(13) "Strong RiskOn"
* 'news' => double(0)
* 'number_news' => int(0)
* 'week_moodix' => double(-0.14)
* 'market_open' => string(1) "1"
* }
* }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment