B
B
Bur Ov2016-08-12 14:01:57
PHP
Bur Ov, 2016-08-12 14:01:57

How to correctly compose an execute VK request?

I have several posts in the array, how can I like them with one request via execute?
I tried this - like is put only on the last entry:

$groups = array('98','97','96','95','94');

for ($i=0; $i < count($groups); $i++) { 
$code = 'return API.likes.add({"owner_id": -11518007, "item_id": '.$groups[$i].', "type":"post"});';
}
$parameters = ['code' => $code];
$test = $vk->getData('execute', $parameters, true);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Дмитрий Евграфович, 2016-08-12
@burov0798

Почитайте о конкатенации строк сначала, а затем сделайте так, чтобы return один был в отправляемом вами методе. Вы в цикле строку переписываете. Echo $code после цикла вставьте чтобы увидеть.
Сначала попробуйте правильную строку на странице с описанием метода в документации vk составить, затем ее уже в цикле php воссоздавайте.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question