Answer the question
In order to leave comments, you need to log in
How to rewrite code from file_get_contents to CURL?
Hello.
I am developing for myself one thing in php, which uses api vk. I didn’t want to go deep into the theory, so I just took a ready-made example and remade it to fit my needs. Here's what happened:
function get_group_info($group_vkid){
$url = 'https://api.vk.com/method/groups.getById';
$params = array(
'group_id' => $group_vkid,
'fields' => 'members_count',
'access_token' => '6222b2f6a4afc0e0dd327db7bd0d84cd91726acffee9ae8e338c09997d3a184879e02ae632764156e3edf',
'v' => '5.59'
);
$result = file_get_contents($url, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params)
)
)));
$result = json_decode($result, 1);
return $result[response][0];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question