VK通过php自动发布在墙上

I would like to post on my wall in vk.com some photos, texts, etc via PHP. From a couple of days I'm trying to understand the official guides of VK (https://vk.com/dev/PHP_SDK) and some scipt found in GitHub (https://github.com/fdcore/vk.api).

There are few lines of code but I struggle to get to the second or third line.

I get immediately php errors, JSON errors, etc etc etc. I can't even make myself give the first Access_token, Autorization_code etc. I admit I don't understand much about OAuth and API, but here I can't even begin.

Even the names of things are strange, secret_key, secure_key, api_key, I think they are always the same, but I'm not sure anymore, but they one gives me, I think it's her.

Do these APIs work? Is there a guide for dummy? That you guide me step-by-step, just to understand if I did something wrong, even if I made very few steps.

Or maybe there is some other script or class that works?

I'm guessing as a start, you will need code similar to below, not forgetting about downloading the VK class library from Github https://github.com/fdcore/vk.api/blob/v2/src/vk.php.

<?php

    // Need to have the vk.php in the same directory.
    include 'vk.php';

    // Please complete the below with your details/credentials.
    $config['secret_key'] = '';
    $config['client_id'] = '';
    $config['user_id'] = '';
    $config['access_token'] = '';
    $config['scope'] = 'wall,photos,friends,groups';

    // Get a new instance of VK.
    $v = new Vk($config);

    // Define the attachment to insert, in this case an image.
    $attachments = $v->upload_photo(0, array('1737759.jpg'));

    // Post the message and image to your wall.
    $response = $v->wall->post(array(
       'message'=>'test 1737759.jpg',
       'attachments' => implode(',', $attachments)
    ));

?>

The class deals with all of the behind the scene coding and talking to Vk as a whole. And why reinvent the wheel!

Everybody stop!

I deleted the application and I made a new one... and it works... I have a working URL and a working token.

However it is strange, these days I have done many tests tried many scripts and created and deleted apps several times always with the same settings (Standalone)... Just now he liked it and it worked...

Now with the code that gave me Jim Grant and the token, everything works, I can upload photos on the wall of VK via PHP.

To have the URL with the token I used this:

$v = new Vk(array(
    'client_id' => 123456, // (required) app id
    'secret_key' => '', // (required) get on https://vk.com/editapp?id=12345&section=options
    'user_id' => 12345, // your user id on vk.com
    'scope' => 'wall,photos,friends,groups', // scope access
    'v' => '5.52' // vk api version
));

$url = $v->get_code_token();

echo $url;

Then I granted the permissions and took the token from the URL in the address bar.

And then I used the Jim Grant code with the new token, and everything works. Really simple, when everything works.