H
H
HaruAtari2014-04-02 13:48:20
PHP
HaruAtari, 2014-04-02 13:48:20

PHP: how to automatically add posts to the VKontakte community wall?

There is a site on puff (yii). The site has a group in contact. We need the ability to leave posts on the group wall from our server. ON behalf of a group or, if necessary, a special user.
The problem is that I can't login.

$res = file_get_contents('https://oauth.vk.com/access_token?client_id='.$clientId.'&client_secret='.$secret.'&grant_type=client_credentials');
$token = json_decode($res, true)['access_token'];

After that, I make a request to the desired address using file_get_contents or curl. Returns an error - "error_code":5,"error_msg":"User authorization failed: method is unavailable with server auth."
In docks it is written that only client authorization is available. But there must be a way to do it from the server.
Already quite confused. Tell me, maybe there is a ready-made class for this or an article that explains how to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HaruAtari, 2014-06-16
@HaruAtari

Everything turned out to be simple. Make a request via curl and save the cookies that the server issues. Then everything works.

A
Alexander Khirenko, 2014-04-02
@Satanpit

You can get a token once by writing the link manually with the necessary scope and add offline there.
You can use the received token for an unlimited amount of time.
Here is a detailed description dudev.ru/blog/20_styena-vk.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question