vp2vk@dock2:~ [0] $ composer-php7.2 update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
vp2vk@dock2:~ [2] $ composer-php7.2 install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 1 install, 0 updates, 0 removals
- Installing vkcom/vk-php-sdk (5.80.1): Downloading (100%)
Generating autoload files
7.2
composer-php7.2 require vkcom/vk-php-sdk
VKOAuth(), ругается на
Class 'VKOAuthDisplay' not found
/public_html/vendor/autoload.php
$vk = new VK\Client\VKApiClient();
$oauth = new VK\Client\VKOAuth();
$client_id = API_CLIENT_ID;
$redirect_uri = 'http://site.ru/index.php';
$display = VKOAuthDisplay::PAGE;
$scope = array(VKOAuthUserScope::WALL, VKOAuthUserScope::GROUPS);
$state = 'secret_state_code';
$browser_url = $oauth->getAuthorizeUrl(VKOAuthResponseType::CODE, $client_id, $redirect_uri, $display, $scope, $state);
HTTP ERROR 500
$photo
сразу за //print_r($photo);
<?php
require_once '../sys/config.php';
class Model_VK {
public $access_token, $v;
const API = 'https://api.vk.com/method/';
public function __construct($access_token, $v){
$this->access_token = $access_token;
$this->v = $v;
}
public function uploadImage($file, $group_id = null, $album_id = null){
list($params['group_id'], $params['album_id']) = [$group_id, $album_id];
$upl = $this->vk('photos.getUploadServer', $params)->response->upload_url;
if (isset($upl)) {
$upload = json_decode($this->curl($upl, ['file1' => new CURLFile($file)]));
if (isset($upload->server)) {
$photo = $this->vk('photos.save', [
'server' => $upload->server,
'photos_list' => $upload->photos_list,
'album_id' => $album_id,
'hash' => $upload->hash,
'group_id' => $group_id
]);
//print "<pre>"; print_r($photo);
return $photo;
}
- ПРОБОВАЛ СЮДА
}
- ПРОБОВАЛ СЮДА
}
- ПРОБОВАЛ СЮДА
public function vk($method, $params){
list($params['access_token'], $params['v']) = [$this->access_token, $this->v];
return json_decode($this->curl(self::API . $method, $params));
}
public function curl($url, $params = false) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (isset($params)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
$upd = curl_exec($ch);
curl_close($ch);
return $upd;
}
}
$new = new Model_VK(mc_decrypt($_SESSION['UserInfo']['master_token'], ENCRYPTION_KEY), $System['api']['version']);
$new->uploadImage($ThisImg, $GroupID, $AlbumID); // адрес фото / id группы / id альбома
print "<pre>";
print_r($photo);
Просто я считаю что поучать никого не стоит (бесполезное это занятие).
Есть желание - помог, нет - прошел мимо...
Еще раз спасибо, что не прошел! ;)