M
M
Max Friday2018-12-05 12:40:34
PHP
Max Friday, 2018-12-05 12:40:34

file() function not working?

Hello everyone!)
Please tell me, I need to show the authorized user 5 of his friends, for this I wrote the following code:

<?php
         $url = 'https://oauth.vk.com/authorize?client_id=ХХХХХХХ&display=popup&scope=friends,offline&redirect_uri=http://мойсайт&response_type=code&v=5.92' ;
         $code = $_GET['code'];
         $url = 'https://oauth.vk.com/access_token?client_id=ХХХХХХХ&client_secret=секрет&code='.$code.'&redirect_uri=http://мой сайт';
         $result = file_get_contents($url);
         $result = json_decode($result, true);
         $access_token = $result['access_token'];
         $url = 'https://api.vk.com/method/friends.get?user_id=&order=random&count=5&fields=nickname, photo_50&access_token='.$access_token.'&v=5.92';
         $data = file_get_contents($url);
         $data = json_decode($data, true);
         var_dump ($data);
      ?>

As a result, VarDump returns NULL. Before that, file_get_contents works well. If you substitute the received access_token into the link and go through the browser, it shows what you need.
_____________________________
What could be the problem?
Or maybe it needs to be implemented in a different way?
--------------------
I would be overly grateful for the help!)
I'm in the PCP teapot with a teapot, don't judge strictly ..)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question