Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. function vkApi_getserver($api_key) {
  2.   $curl = curl_init('https://api.vk.com/method/appWidgets.getGroupImageUploadServer');
  3.   curl_setopt($curl, CURLOPT_POST, true);
  4.   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  5.   curl_setopt($curl, CURLOPT_POSTFIELDS, array('image_type' => '510x128', 'access_token' => $api_key, 'v' => '5.68'));
  6.   $json = curl_exec($curl);
  7.   curl_close($curl);
  8.   return json_decode($json, true);
  9. }
  10.  
  11.  
  12.  
  13. function vkApi_upload($url, $file_name) {
  14.   $curl = curl_init($url);
  15.   curl_setopt($curl, CURLOPT_POST, true);
  16.   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  17.   curl_setopt($curl, CURLOPT_POSTFIELDS, array('file' => new CURLfile($file_name)));
  18.   $json = curl_exec($curl);
  19.   curl_close($curl);
  20.   return json_decode($json, true);
  21. }
  22.  
  23.  
  24. function vkApi_save($hash, $image, $api_key) {
  25.   $curl = curl_init('https://api.vk.com/method/appWidgets.saveGroupImage');
  26.   curl_setopt($curl, CURLOPT_POST, true);
  27.   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  28.   curl_setopt($curl, CURLOPT_POSTFIELDS, array('hash' => $hash, 'image' => $image, 'access_token' => $api_key, 'v' => '5.68'));
  29.   $json = curl_exec($curl);
  30.   curl_close($curl);
  31.   return json_decode($json, true);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement