M
M
Mikk3572019-05-22 03:19:44
PHP
Mikk357, 2019-05-22 03:19:44

How to make a get request to vk api in PHP?

How to write a get request?
here in python with the requests library like this

zapros = get("https://api.vk.com/method/groups.getLongPollServer?group_id={0}&access_token={1}&v={2}".format(mygroupid,secret_token,'5.95'))

how to do this in php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Savrasov, 2019-05-22
@alcorn

But curl extension must be enabled in php.ini

$queryUrl = 'https://api.vk.com/method/groups.getLongPollServer';
  $queryData = http_build_query(array(
        
      "group_id" =>123,
      "access_token"=>321,
      "access_token"=> 333
  ));
  $curl = curl_init();
  curl_setopt_array($curl, array(
      CURLOPT_SSL_VERIFYPEER => 0,
      CURLOPT_POST => 0,
      CURLOPT_HEADER => 0,
      CURLOPT_RETURNTRANSFER => 1,
      CURLOPT_URL => $queryUrl,
      CURLOPT_POSTFIELDS => $queryData,
  ));
  
  $result = curl_exec($curl);
  curl_close($curl);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question