Examples in PHP 5

Get a token

JSON with file_get_contents
JSON with the cURL library
SOAP with the SoapClient class

Verify the SSL certificate

When using the SSL protocol with PHP prior to version 5.6.0, verification of the remote server's SSL certificate might be disabled by default, which may lead to man-in-the-middle attacks. If verification is enabled, you may need to specify the path to the certification authority's root certificate.

We recommend enabling verification and, if necessary, setting the path to the CA root certificate file on the local computer.

The Yandex.Direct API servers use an SSL certificate issued by the CERTUM certification authority. You can download the root certificate from the CA's website:,expertise_root_certificates.xml#CCA. Go to the section Certum root certificates and click the link Download: PEM (for the CA.pem file).

Each example includes a section with instructions on enabling SSL certificate verification and setting the path to the root certificate.