Не получилось, были ошибки в синтаксисе, их долго исправлял, в итоге вышло примерно так:
Спойлер (Отобразить)
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- function sendimage($uid, $mess, $dir){
- global $token; // токен рабочий
- $method = 'photos.getMessagesUploadServer';
- curl_setopt($curl, CURLOPT_URL, 'https://api.vk.com/method/' . $method . '?' . $pars . '&access_token=' . $token);
- function curl_file_create($filename, $mimetype = '', $postname = '') {
- return "@$filename;filename="
- . ($mimetype ? ";type=$mimetype" : '');
- }
- }
- //--------------------------------------------------------------------------------------
- //Проблема начинается примерно здесь:
- $dir = curl_file_create($dir, $info['mime'], $basename['basename']);
- //pre($dir);
- //curl_setopt($curl, CURLOPT_POSTFIELDS, array('filename' => $dir));
- //До сюда
- //--------------------------------------------------------------------------------------
- pre($response_image);//выводит пустой массив
- //Дальше все обычно:
- /*$message = VK::request('photos.saveMessagesPhoto' . 'server=' . $response_image['server'] . '&photo=' . $response_image['photo'] . '&hash=' . $response_image['hash'] . '&access_token=' . $token);
- //VKmes::send('128624053', '150 line');
- pre($message);
- $result_image = json_decode(file_get_contents($message), true);*/
- $method = 'photos.saveMessagesPhoto';
- $pars = 'server=' . $response_image['server'] . '&photo=' . $response_image['photo'] . '&hash=' . $response_image['hash'];
- curl_setopt($curl, CURLOPT_URL, 'https://api.vk.com/method/' . $method . '?' . $pars . '&access_token=' . $token);
- //pre($result);
- //pre($result_image);
- $mess = VK::request('messages.send', 'user_id=' . $uid . '&message=' . $mess . '&attachment=photo' . $result_image['response']['0']['owner_id'].'_'. $result_image['response']['0']['id'] . '&access_token=' . $token);
- //VKmes::send('128624053', '159 line');
- return $message; //return $mess;
- }