Getting the report file

Shows how to get and output the report file in PHP and Python.

Attention. In the examples below, you must specify the real URL of the report file in the url variable. Use the GetReportList method to get the URL.

PHP

The following PHP example shows how to get a report file using the file_get_contents function.

<?php

/*
    Sample script for getting a file over HTTPS using the file_get_contents function.

*/

    // Specify the actual report URL
    // that is returned by the GetReportList method.
    // ! The URL below is given as an example.
    $url = "https://api.direct.yandex.ru/reports/stat_159da499b.xml";
    $report = file_get_contents($url);
    echo htmlspecialchars($report);
?>

Python

The following Python example shows how to get a report file using the urllib2 module.

# -*- coding: utf_8 -*-
from urllib2 import urlopen

# Specify the actual report URL
# that is returned by the GetReportList method.
# ! The URL below is given as an example.
url = "https://api.direct.yandex.ru/reports/stat_159da499b.xml"
print urlopen(url).read()