<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="get-report-sample-php" xml:lang="en" xsi:noNamespaceSchemaLocation="urn:yandex:names:tc:dita:xsd:yandexTopic.xsd:1.3"Getting the report file
Shows how to get and output the report file in PHP and Python.

Alert

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()