A
A
achuraev2017-01-08 00:44:07
PHP
achuraev, 2017-01-08 00:44:07

Wall.post to public vk in php?

Hello everyone, I have not been in the VK api topic for more than a year. Tell me, after the endless VK updates in 2016, was it possible to post on the wall of the VK group from PHP? I did it like before, I received the token through the Standalone application, I remember that such a scheme worked before. Now it gives an error on the token that it does not have enough rights for this method.
PS: I see different SMM applications, they seem to post without any problems. If someone knows what the secret is, tell me, Google is empty, only old methods.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
K. A., 2017-01-08
@achuraev

You need to request a token with the rights of wall and groups, according to the Implicit flow scheme - i.e. specify the address https://oauth.vk.com/blank.html in the redirect_uri parameter , or not specify at all. I used this approach: I received a token according to this scheme, and then JS parsed the address up to the # symbol and wrote the token to the database, I received it with group, wall, offline rights. Then I just checked it before each post, and if the token turned out to be dead, I performed the authorization again. The only inconvenience was to ask the user to copy the address from the authorization window that opened, in which there was a token. Otherwise, the rights to the wall are simply ignored. This approach is quite acceptable when one admin wants to do a crosspost when adding news to the site. In other cases - somehow it is necessary to get out differently.

I
ivkol, 2017-01-08
@ivkol

C# code. Just checked. Token via standalone. Maybe it will help (on php is not at hand)

private void sendMessage(string msg)
        {
              
                string url = "https://api.vk.com/method/wall.post?owner_id=" + Convert.ToString(id_group);
                url += "&message=" + msg;
                url += "&v=5.21";
                url += "&access_token=" + token;

                lblLog.Text = Response(url);   
            
        }

        private string Response(string request_path)    //на вход подаем URL API
        {
            string response = string.Empty;
            HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(request_path);   //отправление запроса к серверу API
            HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();      //получение ответа от сервера API
            Stream receiveStream = Response.GetResponseStream();
            Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
            StreamReader readStream = new StreamReader(receiveStream, encode);

            Char[] read = new Char[256];
            int count = readStream.Read(read, 0, 256);

            while (count > 0)
            {
                String line = new String(read, 0, count);
                response += line + "\r\n";
                count = readStream.Read(read, 0, 256);
            }

            Response.Close();
            readStream.Close();

            return response;
        }

K
Kirill Zhilyaev, 2017-01-08
@kirill_782

Manually, the token records everything. It's just that they once made an update, which allowed standalone to use rederict url and token name similar rights to sites. Just forward the rederict url in the browser, pull out the token from the address bar and paste it into php. This is how I moderate the wall. You can beg from SPP for access to the wall for sites, as some posting sites did

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question