Пример #1
0
function example11($api_key, $symbol)
{
    $quandl = new Quandl($api_key, "csv");
    $result = $quandl->getSymbol("DEBUG/INVALID");
    if ($quandl->error and !$result) {
        return $quandl->error . " - " . $quandl->last_url;
    }
    return $result;
}
Пример #2
0
<?php

//--------------------------------------------------------------
// Example: Quandl API with Cache
//--------------------------------------------------------------
require_once "Quandl.php";
$api_key = "YOUR_KEY_HERE";
$quandl = new Quandl($api_key, "csv");
$quandl->cache_handler = 'cacheHandler';
$data = $quandl->getSymbol("GOOG/NASDAQ_AAPL");
// A simple example of a cache handler.
// This function will be called by the Quandl class.
// When action == "get", you should return a cached
// object or false.
// When action == "set", you should perform the save
// operation to your cache.
function cacheHandler($action, $url, $data = null)
{
    $cache_key = md5("quandl:{$url}");
    $cache_file = __DIR__ . "/{$cache_key}";
    if ($action == "get" and file_exists($cache_file)) {
        return file_get_contents($cache_file);
    } else {
        if ($action == "set") {
            file_put_contents($cache_file, $data);
        }
    }
    return false;
}
Пример #3
0
 private function _testBulk($force_curl = false)
 {
     if (!$this->premium_database) {
         $this->markTestSkipped('Premium database is not available. Use QUANDL_PREMIUM environment variable to set a database for testing');
         return;
     }
     $quandl = new Quandl($this->api_key);
     $quandl->force_curl = $quandl->no_ssl_verify = $force_curl;
     $filename = "tmp.zip";
     @unlink($filename);
     $this->assertFileNotExists($filename);
     $r = $quandl->getBulk($this->premium_database, $filename);
     $this->assertFileExists($filename);
     $this->assertGreaterThan(100000, filesize($filename));
 }