---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.2
alternate:
  - https://yandex.ru/dev/direct/doc/dg-v4/en/examples/get-report-sample-php.md
  - https://yandex.ru/dev/direct/doc/dg-v4/ru/examples/get-report-sample-php.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/direct/doc/dg-v4/en/llms.txt

<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.<body >

{% note alert %}

In the examples below, you must specify the real URL of the report file in the `url` variable. Use the [GetReportList](https://yandex.ru/dev/direct/doc/dg-v4/en/reference/GetReportList.md) method to get the URL.

{% endnote %}

# PHP

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

```php
<?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.

```python
# -*- 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()
```
</body></topic>