Все работает, но в конце я получаю [api] request appWidgets.saveGroupImage failed (code=129 msg='Invalid photo: file not found, from upl_855432?act=app_widget_image')
и не могу понять как решить проблему
Картинка в разрешении 24x24
<?php
$upl_url = vk_api_call('appWidgets.getGroupImageUploadServer', array(
'image_type' => "24x24"));
$link = $upl_url['upload_url'];
$lala = dirname(__FILE__)."/online.jpg";
$cfile = curl_file_create($lala,'image/jpeg','online.jpg');
$curl=curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $link,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array("photo" => $cfile)
));
$response = curl_exec($curl);
$res = json_decode($response, true);
$mem =$res['hash'];
$memimage =$res['image'];
print_r($res);
$finish = vk_api_call('appWidgets.saveGroupImage', array(
'hash' => $mem, 'image' => $memimage ));
print_r($finish);
function vk_api_call($method, $params = array())
{
return vk_call($method, "ТОКЕН", $params);
}
function vk_call($method, $token, $params = array())
{
if(!isset($params['lang'])) {
$params['lang'] = "ru";
}
if(!isset($params['v'])) {
$params['v'] = "5.80";
}
if(!isset($params['access_token'])) {
$params['access_token'] = $token;
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.vk.com/method/".$method);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$response = curl_exec($curl);
curl_close($curl);
if($response === false) {
return false;
}
$data = json_decode($response, true);
if($data === false) {
return false;
}
if(!isset($data['response']))
{
logs("[api] request ".$method." failed (code=".$data['error']['error_code']." msg='".$data['error']['error_msg']."')");
return false;
}
logs("[api] request ".$method." successful");
return $data['response'];
}
function logs($line)
{
print(sprintf("[%s] %s\n", date(DATE_ATOM, time()), $line));
}