Фото от имени группы (Standalone)

Создание Desktop-приложений, виджеты ВКонтакте для сайтов и публичных страниц, OAuth 2.0, Open API, Standalone
Ответить
alex23527
Сообщения: 2
Зарегистрирован: 21 июн 2014, 23:48

Фото от имени группы (Standalone)

Сообщение alex23527 »

Привет Всем!
Ситуация такова: есть Standalone приложение с помощью которого я делаю автопостинг в группу ВК.
Автопостинг работает через файл VKPublic.php
Вот его код:
 Код файла

Код: Выделить всё

<?phpclass VKPublic{    protected $groupId, $appId, $secretKey, $accessToken, $accessSecret;     /**     * @param int $groupId     * @param int $appId     * @param string $secretKey     */    public function __construct($groupId, $appId, $secretKey)    {        $this->groupId = $groupId;        $this->appId = $appId;        $this->secretKey = $secretKey;    }     /**     * @param string $accessToken     * @param string $accessSecret     */    public function setAccessData($accessToken, $accessSecret)    {        $this->accessToken = $accessToken;        $this->accessSecret = $accessSecret;    }     /**     * Hack     */    public function getAccessData()    {        echo "<!doctype html><html><head><meta charset='utf-8'></head>            <body><a href='http://api.vk.com/oauth/authorize?" .            "client_id={$this->appId}&scope=offline,wall,groups,pages," .            "photos,docs,audio,video,notes,stats,messages,notify,notifications,nohttps&" .            "redirect_uri=http://api.vk.com/blank.html&response_type=code'                target='_blank'>Получить CODE</a><br>Ссылка для получения токена:<br>                <b>https://api.vk.com/oauth/access_token?client_id={$this->appId}" .            "&client_secret={$this->secretKey}&code=CODE&redirect_uri=http://api.vk.com/blank.html&response_type=code</b></body></html>";         exit;    }     /**     * @param string $method     * @param mixed $parameters     * @return mixed     */    public function callMethod($method, $parameters)    {        if (!$this->accessToken) return false;        if (is_array($parameters)) $parameters = http_build_query($parameters);        $queryString = "/method/$method?$parameters&access_token={$this->accessToken}";        $querySig = md5($queryString . $this->accessSecret);        return json_decode(file_get_contents(            "http://api.vk.com{$queryString}&sig=$querySig"        ));    }     /**     * @param string $message     * @param bool $fromGroup     * @param bool $signed     * @return mixed     */    public function wallPostMsg($message, $fromGroup = true, $signed = false)    {        return $this->callMethod('wall.post', array(            'owner_id' => -1 * $this->groupId,            'message' => $message,            'from_group' => $fromGroup ? 1 : 0,            'signed' => $signed ? 1 : 0,        ));    }     /**     * @param string $attachment     * @param null|string $message     * @param bool $fromGroup     * @param bool $signed     * @return mixed     */    public function wallPostAttachment($attachment, $message = null, $fromGroup = true, $signed = false)    {        return $this->callMethod('wall.post', array(            'owner_id' => -1 * $this->groupId,            'attachment' => strval($attachment),            'message' => $message,            'from_group' => $fromGroup ? 1 : 0,            'signed' => $signed ? 1 : 0,        ));    }     /**     * @param string $file relative file path     * @return mixed     */    public function createPhotoAttachment($file)    {        $result = $this->callMethod('photos.getWallUploadServer', array(            'gid' => $this->groupId        ));         $ch = curl_init($result->response->upload_url);        curl_setopt($ch, CURLOPT_HEADER, false);        curl_setopt($ch, CURLOPT_POST, true);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        curl_setopt($ch, CURLOPT_POSTFIELDS, array(            'photo' => '@' . getcwd() . '/' . $file        ));         if (($upload = curl_exec($ch)) === false) {            throw new Exception(curl_error($ch));        }         curl_close($ch);        $upload = json_decode($upload);        $result = $this->callMethod('photos.saveWallPhoto', array(            'server' => $upload->server,            'photo' => $upload->photo,            'hash' => $upload->hash,            'gid' => $this->groupId,        ));         return $result->response[0]->id;    }     public function combineAttachments()    {        $result = '';        if (func_num_args() == 0) return '';        foreach (func_get_args() as $arg) {            $result .= strval($arg) . ',';        }        return substr($result, 0, strlen($result) - 1);    }}?>
Автопостинг происходит так

Код: Выделить всё

 require_once 'VKPublic.php';$public = new VKPublic(айди_группы, айди_приложения, Защищенный_ключ);$public->setAccessData(access_token, acces_secret); $attachments = $public->combineAttachments(     $public->createPhotoAttachment('images_items_vk/1.jpg'), // Картинка в посте   'http://site.ru/?product='.$result_select_item_for_vk['prod_link'] // Ссылка в посте    );$public->wallPostAttachment($attachments, $mess_vk_post); // Сообщение с аттачем
Проблема: Фотография в посте, постится от моего имени (Алексей Борисов), а не от имени группы.

Вопрос: Как сделать чтобы фотография постилась от имени группы?

PS В крупных пабликах, гда есть автопостинг на основе приложений, например Feedman фотка постится от имени группы или паблика. Курение мануалов апи ВК не помогло (

Помогите пожалуйста.
Ответить