H
H
HabrDima202021-12-22 10:33:10
Parsing
HabrDima20, 2021-12-22 10:33:10

How to get data through proxy?

The problem is this.
I get data via API.
The data that comes in them has a picture (link to the Yandex disk to the picture itself).
Since I am from Ukraine, Yandex is banned.
When I did it on LAN, I turned on vpn and everything was downloaded. Now posted on a server in Europe.
And it does not work, it is impossible to pull out the picture. I can not understand why, if the site is in Europe.
I try through proxy, does not work.
How to solve the problem?
Connect vpn on server, proxy?

curl_setopt_array($curl, array(
            CURLOPT_URL => $this->url,
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => 1,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'GET',

            CURLOPT_PROXY => $this->proxy,
            CURLOPT_PROXYUSERPWD => $this->userpwd,
            CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,

            CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36',
            CURLOPT_HTTPHEADER => array(
                'Accept: application/json',
                'X-API-KEY: '.$this->apiKey,
            ),
        ));


If I connect a proxy, it returns false . I get data without a proxy, but the picture does not save.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2021-12-22
@zkrvndm

https://qna.habr.com/q/927913

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question