deep-foundation / deep-packages

This is repository for packages that are published only in NPM.
https://github.com/orgs/deep-foundation/projects/12
The Unlicense
0 stars 2 forks source link

Export VK user's wall to GitHub Pages #50

Open Konard opened 9 months ago

Konard commented 9 months ago

This package should generate HTML page that is then published to a selected repository as index.html.

At first, we should just use iframes that display VK posts as is.

Later, we may create complete snapshots of the user's posts.

Konard commented 9 months ago

GPT-4 answer

First, to start dealing with VK API using Node.js, you have to install the needed package by running this command:

npm install vk-io

Then, you need to write Node.js script like the following to get the list of wall posts from VK API:

const VK = require('vk-io');
const vk = new VK({
    token: 'YOUR_TOKEN'
});

vk.api.users.get({
    user_id: 'PUT_USER_ID_HERE'
}).then(res => {
     vk.api.wall.get({
         owner_id: res[0].id,
         count: 10
     }).then((wallPosts) => {
         console.log('Recent 10 posts on the wall:')
         if (!wallPosts.items.length) {
            console.log('No posts found.');
            return;
         }

         wallPosts.items.forEach((post) => {
             console.log(`https://vk.com/wall${res[0].id}_${post.id}`);
         });
     });
}).catch(console.error);

Please replace 'YOUR_TOKEN' and 'PUT_USER_ID_HERE' with your Token and the User ID respectively.

This script will output the last 10 posts URL on the console. You can modify it to get the URLs and IDs in another useful place.

Remember, VK token gives the app the functionality to read the wall posts and IDs. So, you need to generate a VK token. If you plan to make it a publicly available app, make sure to follow VK API User Authorization process.

Also, here's a useful link to VK's Official API Reference. It should have everything you need to start requesting posts from VK's API.