2017 © Pedro Peláez
 

library vk-api

FreedomCore VK API Library

image

freedomcore/vk-api

FreedomCore VK API Library

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

[PHP] FreedomCore VK API

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Downloads Month License, (*1)

A PHP VK API Client based on official VK API Documentation, (*2)

Table of Contents

Introduction

This is a pure PHP implementation of VK API Client library. It can be easy extended by adding additional resource classes to API folder., (*3)

Pros: - Can authorize users with specific scope - Can check for required scope before executing API call - Works with: Users, Groups, DataStorage, Account and Documents APIs - Easy to modify - Easy to use, (*4)


This code is available on Github. Pull requests are welcome., (*5)

Require this package with Composer

Install this package through Composer. Edit your project's composer.json file to require freedomcore/vk-api., (*6)

Create composer.json file, (*7)

{
    "name": "nameofyourproject/nameofyourproject",
    "type": "project",
    "require": {
        "php": ">=5.6.0",
        "freedomcore/vk-api": "*"
    }
}

and run composer update, (*8)

or, (*9)

run this command in your command line:, (*10)

composer require freedomcore/vk-api

Configuration

  1. Create New Object
    a. To work with Library before authorization completed
    $vkObject = new FreedomCore\VK\VKBase('{APPLICATION_ID}', '{API_SECRET}');
    b. To work with Library after authorization completed
    $vkObject = new FreedomCore\VK\VKBase('{APPLICATION_ID}', '{API_SECRET}', '{ACCESS_TOKEN}');
  2. How to authorize user
    a. Generate Authorization Link
    $vkObject->getAuthorizationURL('{SCOPE}', '{CALLBACK_URL}');
    b. Get Access Token By Using Key From Callback
    $vkObject->getAccessToken('{CODE}');
    c. Check, if user authorized
    $vkObject->isAuthorized(); // returns true | false
  3. Now you can work with API

Resources

VKBase Resource

This is the main Library resource, (*11)

There are 4 API Methods presented in this Resource:
1. setAPIVersion({API_VERSION}) - Set API Version Provided By User
2. getAuthorizationURL({SCOPE}, {CALLBACK_URL}, {RESPONSE_TYPE}, {TEST_MODE}) - Returns Authorization Link With Passed Parameters
3. getAccessToken({CODE}, {CALLBACK_URL}) - Returns Access Token From Authorization Link
4. isAuthorized() - Returns User Authorization Status, (*12)

VKAccount Resource

This Resource allows you to get user related data, (*13)

How to use:, (*14)

Initialize New VKAccount object:, (*15)

$VKAccount = new FreedomCore\VK\API\VKAccount($vkObject);

Now you can call methods, e.g., (*16)

$getCounters = $VKAccount->getCounters();
$getApplicationPermissions = $VKAccount->getAppPermissions({USER_ID});

There are 6 API Methods presented in this Resource:
1. getCounters({USER_FIELDS optional) - Fetches all counters which are greater than zero (messages, videos, friends, etc)
2. setNameInMenu({USER_ID}, {APPLICATION_NAME} - Creates Sidebar Link to application, if user allowed it
3. setOnline() - Sets status to Online for 15 minutes
4. setOffline() - Sets status to Offline
5. getActiveOffers({OFFSET optional}, {COUNT optional}) - Returns a list of active ads (offers)
6. getAppPermissions() - Gets settings of the current user in this application, (*17)

VKDataStorage Resource

Missing Description, (*18)

There are 3 API Methods presented in this Resource:
1. get({KEY}, {KEYS}, {USER_ID}, {IS_GLOBAL}) - Returns a value of variable with the name set by key parameter
2. set({KEY}, {VALUE}, {USER_ID}, {IS_GLOBAL}) - Saves a value of variable with the name set by key parameter
3. getKeys({USER_ID}, {IS_GLOBAL}, {OFFSET optional}, {COUNT optional}) - Returns the names of all variables, (*19)

VKDocuments Resource

Attention: This Resourse is incomplete | There are 7 more methods to be added, (*20)

This Resource allows you to work with documents which are belong to user/group, (*21)

How to use:, (*22)

Initialize New VKDocuments object:, (*23)

$VKDocuments = new FreedomCore\VK\API\VKDocuments($vkObject);

Now you can call methods, e.g., (*24)

$isMember = $VKDocuments->get(123456, 100); // returns 100 results
$searchForGroups = $VKDocuments->getById('123456_654321'); // gets document by ID

There are 3 API Methods presented in this Resource:
1. get({OWNER_ID}, {COUNT optional}, {OFFSET optional}) - Returns detailed information about user or community documents
2. getById({DOCUMENT_ID_OR_ARRAY_OF_IDS}) - Returns information about documents by their IDs
3. getUploadServer({COMMUNITY_ID}) - Returns the server address for document upload, (*25)

VKGroups Resource

How to use:, (*26)

This Resource allows you to manage groups and work with them, (*27)

Initialize New VKGroups object:, (*28)

$VKGroups = new FreedomCore\VK\API\VKGroups($vkObject);

Now you can call methods, e.g., (*29)

$isMember = $VKGroups->isMember(123456, 654321, 1);
$searchForGroups = $VKGroups->search('FreedomCore');

There are 19 API Methods presented in this Resource:
1. isMember({GROUP_ID}, {USER_ID}, {IS_EXTENDED optional}) - Returns information specifying whether a user is a member of a community
2. getById({GROUP_ID}, {GROUP_FIELDS}) - Returns information about communities by their ID (IDs)
3. get({USER_ID}, {IS_EXTENDED optional}, {FILTER optional}, {GROUP_FIELDS optional}) - Returns a list of the communities to which a user belongs
4. getMembers({GROUP_ID}, {USERS_FIELDS optional}) - Returns a list of community members
5. join({GROUP_ID}, {IS_EVENT optional}) - With this method you can join the group or public page, and also confirm your participation in an event.
6. leave({GROUP_ID}) - With this method you can leave a group, public page, or event.
7. search({QUERY}, {GROUP_TYPE optional}) - Searches for communities by substring.
8. getInvites({IS_EXTENDED optional}) - Returns a list of invitations to join communities and events.
9. getInvitedUsers({GROUP_ID}, {USERS_FIELDS optional}) - Returns invited users list of a community (Requires Moderator Status)
10. banUser({GROUP_ID}, {USER_ID}, {REASON optional}, {COMMENT optional}, {BAN_ENDS optional}, {SHOW_COMMENT optional}) - Adds a user to a community blacklist (Requires Moderator Status)
11. unbanUser({GROUP_ID}, {USER_ID}) - Deletes a user from a community blacklist (Requires Moderator Status)
12. getBanned({GROUP_ID}) - Returns a list of users on a community blacklist (Requires Moderator Status)
13. create({TITLE}, {DESCRIPTION}, {TYPE optional}, {SUB_TYPE optional}) - Creates a new community
14. edit({GROUP_ID}, {TITLE}, {DESCRIPTION}, {SCREEN_NAME}, {ACCESS}, {WEBSITE}, {SUBJECT}) - Edits a community (THIS METHOD INCOMPLETE)
15. getSettings({GROUP_ID}) - Get Group Settings
16. getRequests({GROUP_ID}, {FIELDS optional}, {COUNT optional}) - Get Group Access Requests
17. invite({GROUP_ID}, {USER_ID}) - Invite User To Group (Requires Moderator Status)
18. removeUser({GROUP_ID}, {USER_ID}) - Remove User From Group (Requires Moderator Status)
19. approveRequest({GROUP_ID}, {USER_ID}) - Approve User Request To Join Group (Requires Moderator Status), (*30)

VKUsers Resource

This Resource allows you to work with users and their data, (*31)

How to use:, (*32)

Initialize New VKUsers object:, (*33)

$VKUsers= new FreedomCore\VK\API\VKUsers($vkObject);

Now you can call methods, e.g., (*34)

$isMember = $VKUsers->isMember(123456, 654321, 1);
$searchForGroups = $VKUsers->search('FreedomCore');

There are 6 API Methods presented in this Resource:
1. get({USER_IDS array}, {FIELDS optional}, {CASE optional}) - Returns detailed information on users
2. search({QUERY}, {IS_ONLINE optional}, {FIELDS optional}, {SORT optional}, {COUNT optional}) - Returns a list of users matching the search criteria
3. isAppUser({USER_ID}) - Returns information whether a user installed the application
4. getSubscriptions({USER_ID}, {COMBINE optional}, {FIELDS optional}, {COUNT optional}) - Returns a list of IDs of users and communities followed by the user
5. getFollowers({USER_ID}, {OFFSET optional}, {COUNT optional}, {FIELDS optional}, {CASE optional}) - Returns a list of IDs of followers of the user in question, sorted by date added, most recent first
6. getNearby({LATITUDE}, {LONGITUDE}, {TIMEOUT optional}, {RADIUS optional}, {FIELDS optional}, {CASE optional}) - Get Nearby Users Based On Current Latitude and Longitude, (*35)

The Versions

03/04 2016

dev-master

9999999-dev https://packages.freedomcore.ru/vk

FreedomCore VK API Library

  Sources   Download

CC-BY-SA

The Requires

  • php >=5.6
  • ext-pdo *
  • ext-curl *

 

api library vkontakte vk official freedomcore

01/04 2016

1.0.5

1.0.5.0 https://packages.freedomcore.ru/vk

FreedomCore VK API Library

  Sources   Download

CC-BY-SA

The Requires

  • php >=5.6
  • ext-pdo *
  • ext-curl *

 

api library vkontakte vk official freedomcore