D
D
devil's jackal2019-11-01 01:01:17
PHP
devil's jackal, 2019-11-01 01:01:17

file_get_contents doesn't work. What am I doing wrong?

I'm dumb and don't understand what I'm doing wrong.
enlighten the idiot.
spoiler: I have a server = vds, where everything is set up correctly in php. and file_get_contents work with curl. and the link itself is absolutely correct, how much I checked.

function replyWI($chat,$text,$numbuttons,$buttonsarr = []){
        $arr = '{"buttons":,"inline":true}';
        $arr = json_encode($arr, JSON_UNESCAPED_UNICODE);
        $random_id = random_int(1,9999999);
        $link = 'https://api.vk.com/method/execute?access_token=123123&v=5.103&code=return%20API.messages.send({"random_id":'. $random_id .',"peer_id":'. $chat .',"message":"'. $text .'","group_id":123123123"keyboard": '. $arr .'});';
        return json_decode(file_get_contents($link),true);
    }

replyWI($peer_id,"Текстик.",2,[1 => "ван", 2 => "ту"]);

if I did everything wrong at all - well, help the stupid x) I'm completely blind
PS: tags are like this because it's for a bot. yes, I decided to make a function, instead of a bunch of code - why insert the same thing everywhere when you can make a function.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2019-11-01
@zkrvndm

At one time, get content didn’t work for me either, I couldn’t understand what the problem was at point-blank range. It turned out that the problem was not in the script, but in the fact that the end site was blocking all requests from suspicious user agents. In short, setting the correct header helped me, disguised the user agent as chrome and it all worked.
Try it yourself:
https://yandex.ru/search/touch/?text=file_get_cont...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question