Skip to content

ExsyDev/vk

 
 

Repository files navigation

VK API

vk api

Total Downloads Latest Stable Version Latest Unstable Version License

Quality Score Build Status StyleCI PHP-Eye

Menu

Installation

To get the latest version of package for VK API, simply require the project using Composer:

$ composer require andrey-helldar/vk

Instead, you may of course manually update your require block and run composer update if you so choose:

{
    "require": {
        "andrey-helldar/vk": "5.63.*"
    }
}

The version of this package is based on the VK API version and has the following appearance: x.y.z, when:

  • x - Major version of VK API.
  • y - Minor version of VK API.
  • z - Version of this package.

Once package is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.

  • Helldar\Vk\VkServiceProvider::class,

Next, execute:

$ php artisan vendor:publish
$ php artisan migrate

Add the following lines to .env:

VK_CLIENT_ID=
VK_CLIENT_SECRET=
VK_SECRET_KEY=

when:

  • VK_CLIENT_ID - Application ID
  • VK_CLIENT_SECRET - Secure key
  • VK_SECRET_KEY - Service token

See more at vk.com/dev

Alright! Use vk() helper.

[ to top | to menu ]

Update package

During development, we sometimes make changes to the structure of the database table, so after updating to a more recent version, run the command:

$ php artisan migrate

[ to top | to menu ]

Requests & responses

ATTENTION!

For correct work this package user must be authorized on site.

[ to top | to menu ]

Template

This package using Authorization Code Flow method to VK API (for server side of an application).

You can call the standard method for creating a button in a template:

{!! vk()->authButton() !!}

or just use the route:

{{ route('vk::auth') }}

[ to top | to menu ]

Send request

To send a request, use the following structure:

// vk()->{section}({method})->param1(value1)->param2(value2)->...->paramN+1(valueN+1)->send();
// Example:
vk()->friends('get')->userId(14)->count(20)->send();
vk()->account('banUser')->userId(14)->send();

[ to top | to menu ]

Get response

To test and receive a response from the API, use the get() method:

// vk()->{section}({method})->get();
// Example:
vk()->friends('get')->get();
vk()->account('banUser')->get();

[ to top | to menu ]

Available methods

Account

  • banUser (1) - Adds user to the banlist.
  • changePassword (1) - Changes a user password after access is successfully restored with the auth.restore method.
  • getActiveOffers (2) - Returns a list of active ads (offers) which executed by the user will bring him/her respective number of votes to his balance in the application.
  • getAppPermissions (2) - Gets settings of the user in this application.
  • getBanned (1) - Returns a user's blacklist.
  • getCounters (2) - Returns non-null values of user counters.
  • getInfo (1) - Returns current account info.
  • getProfileInfo (1) - Returns the current account info.
  • getPushSettings (1) - Gets settings of push notifications. Access rights required: messages.
  • lookupContacts (1) - Allows to search the VK users using phone numbers, e-mail addresses and user IDs on other services. You may get these users by friends.getSuggestions method as well. Access rights required: friends.
  • registerDevice (1) - Subscribes an iOS/Android/Windows Phone-based device to receive push notifications. Access rights required: messages.
  • saveProfileInfo (1) - Edits current profile info.
  • setInfo (1) - Allows to edit the current account info.
  • setNameInMenu (2) - Sets an application screen name (up to 17 characters), that is shown to the user in the left menu. This happens only in case the user added such application in the left menu from application page, from list of applications and settings.
  • setOffline (1) - Marks a current user as offline.
  • setOnline (1) - Marks the current user as online for 15 minutes.
  • setPushSettings (1) - Change push settings. Access rights required: messages.
  • setSilenceMode (1) - Mutes push notifications for the set period of time. Access rights required: messages.
  • unbanUser (1) - Deletes user from the blacklist.
  • unregisterDevice (1) - Unsubscribes a device from push notifications. Access rights required: messages.

See more at VK API: Account

[ to top | to menu ]

Ads

API for VK advertising account is being beta tested. In case of any error or problem with API, please contact us at api@vk.com.

Before you can call API methods, authorize at server or client end. After it you can make any API requests using a standard interaction pattern.

Also, prior to start with Ads API, read limitations and recommendations.

Below there is a list of all methods for operations with the data of VK advertising accounts.

Access rights required: ads.

  • addOfficeUsers (2) - Adds managers and/or supervisors to advertising account.
  • checkLink (2) - Allows to check the ad link.
  • createAds (2) - Creates ads. Please note! Maximum allowed number of ads created in one request is 5. Minimum size of ad audience is 50 people.
  • createCampaigns (2) - Creates advertising campaigns. Please note! Allowed number of campaigns created in one request is 50.
  • createClients (2) - Creates clients of an advertising agency. Available only for advertising agencies. Please note! Allowed number of clients created in one request is 50.
  • createTargetGroup (2) - Creates a group to re-target ads for users who visited advertiser's site (viewed information about the product, registered, etc.).
  • deleteAds (2) - Archives ads.
  • deleteCampaigns (2) - Archives advertising campaigns.
  • deleteClients (2) - Archives clients of an advertising agency. Available only for advertising agencies.
  • deleteTargetGroup (2) - Deletes a retarget group.
  • getAccounts (2) - Returns a list of advertising accounts.
  • getAds (2) - Returns number of ads.
  • getAdsLayout (2) - Returns descriptions of ad layouts.
  • getAdsTargeting (2) - Returns ad targeting parameters.
  • getBudget (2) - Returns current budget of the advertising account.
  • getCampaigns (2) - Returns a list of campaigns in an advertising account.
  • getCategories (2) - Returns a list of possible ad categories.
  • getClients (2) - Returns a list of advertising agency's clients. Available only for advertising agencies.
  • getDemographics (2) - Returns demographics for ads or campaigns.
  • getFloodStats (2) - Returns information about current state of a counter — number of remaining runs of methods and time to the next counter nulling in seconds.
  • getOfficeUsers (2) - Returns a list of managers and supervisors of advertising account.
  • getPostsReach (2) - Returns a posts reach.
  • getRejectionReason (2) - Returns a reason of ad rejection for pre-moderation.
  • getStatistics (2) - Returns statistics of performance indicators for ads, campaigns, clients or the whole account.
  • getSuggestions (2) - Returns a set of auto-suggestions for various targeting parameters.
  • getTargetGroups (2) - Returns a list of target groups.
  • getTargetingStats (2) - Returns the size of targeting audience, and also recommended values for CPC and CPM.
  • getUploadURL (2) - Returns URL to upload an ad photo to.
  • getVideoUploadURL (2) - Returns URL to upload an ad video to.
  • importTargetContacts (2) - Imports a list of advertiser's contacts to count VK registered users against the target group. Please note! Maximum allowed number of contacts imported in one request is 1000.
  • removeOfficeUsers (2) - Removes managers and/or supervisors from advertising account.
  • updateAds (2) - Edits ads. Please note! Allowed number of ads edited in one request is 20. Minimum size of ad audience is 50 people.
  • updateCampaigns (2) - Edits advertising campaigns.
  • updateClients (2) - Edits clients of an advertising agency. Available only for advertising agencies. Please note! Maximum allowed number of clients edited in one request is 50.
  • updateTargetGroup (2) - Edits a retarget group.

See more at VK API: Ads

[ to top | to menu ]

Apps

  • deleteAppRequests (1) - Deletes all request notifications from the current app.
  • get (2) - Returns applications data.
  • getCatalog (2) - Returns a list of applications (apps) available to users in the App Catalog. You may call this method no more that 60 times in one minute from the same IP address or ID.
  • getFriendsList (2) (1) - Creates friends list for requests and invites in current app.
  • getLeaderboard (2) - Returns players rating in the game.
  • getScore (2) - Returns user score in app.
  • sendRequest (1) - Sends a request to another user in an app that uses VK authorization.

See more at VK API: Apps

[ to top | to menu ]

Auth

  • checkPhone (3) - Checks a user's phone number for correctness.
  • confirm (3) - Completes a user's registration (begun with the auth.signup method) using an authorization code.
  • restore (2) - Allows to restore account access using a code received via SMS.
  • signup (3) - Registers a new user by phone number.

See more at VK API: Auth

[ to top | to menu ]

Board

Access rights required: groups.

  • addTopic (1) - Creates a new topic on a community's discussion board.
  • closeTopic (1) - Closes a topic on a community's discussion board so that comments cannot be posted.
  • createComment (1) - Adds a comment on a topic on a community's discussion board.
  • deleteComment (1) - Deletes a comment on a topic on a community's discussion board.
  • deleteTopic (1) - Deletes a topic from a community's discussion board.
  • editComment (1) - Edits a comment on a topic on a community's discussion board.
  • editTopic (1) - Edits the title of a topic on a community's discussion board.
  • fixTopic (1) - Pins a topic (fixes its place) to the top of a community's discussion board.
  • getComments (2) - Returns a list of comments on a topic on a community's discussion board.
  • getTopics (2) - Returns a list of topics on a community's discussion board.
  • openTopic (1) - Re-opens a previously closed topic on a community's discussion board.
  • restoreComment (1) - Restores a comment deleted from a topic on a community's discussion board.
  • unfixTopic (1) - Unpins a pinned topic from the top of a community's discussion board.

See more at VK API: Board

[ to top | to menu ]

Database

These methods provide access to VK's database of educational institutions. Access to data is free and authorization is not required, but the number of requests from one IP address can be limited. If you need to execute many requests, we recommend that you call these methods from the client side using JSONP.

Access rights required: groups.

  • getChairs (2) - Returns list of chairs on a specified faculty.
  • getCities (2) - Returns a list of cities.
  • getCitiesById (2) - Returns information about cities by their IDs.
  • getCountries (2) - Returns a list of countries.
  • getCountriesById (2) - Returns information about countries by their IDs.
  • getFaculties (2) - Returns a list of faculties (i.e., university departments).
  • getRegions (2) - Returns a list of regions.
  • getSchoolClasses (2) - Returns a list of school classes specified for the country.
  • getSchools (2) - Returns a list of schools.
  • getStreetsById (2) - Returns information about streets by their IDs.
  • getUniversities (2) - Returns a list of higher education institutions.

See more at VK API: Database

[ to top | to menu ]

Docs

Access rights required: docs.

  • add (2) - Copies a document to a user's or community's document list.
  • delete (2) - Deletes a user or community document.
  • edit (2) - Edits a document.
  • get (2) - Returns detailed information about user or community documents.
  • getById (2) - Returns information about documents by their IDs.
  • getTypes (2) - Returns documents types available for current user.
  • getUploadServer (2) - Returns the server address for document upload.
  • getWallUploadServer (2) (4) - Returns the server address for document upload onto a user's or community's wall.
  • save (2) (4) - Saves a document after uploading it to a server.
  • search (2) (4) - Returns a list of documents matching the search criteria.

See more at VK API: Docs

[ to top | to menu ]

Execute

  • execute (2) (3) - A universal method for calling a sequence of other methods while saving and filtering interim results.

See more at VK API: Execute

[ to top | to menu ]

Friends

Access rights required: messages.

  • add (1) - Approves or creates a friend request.
  • addList (1) - Creates a new friend list for the current user.
  • areFriends (2) - Checks the current user's friendship status with other specified users. Also returns information specifying whether there is an outgoing or incoming friend request (new follower).
  • delete (1) - Declines a friend request or deletes a user from the current user's friend list.
  • deleteAllRequests (1) - Marks all incoming friend requests as viewed.
  • deleteList (1) - Deletes a friend list of the current user.
  • edit (1) - Edits the friend lists of the selected user.
  • editList (1) - Edits a friend list of the current user.
  • get (2) - Returns a list of user IDs or detailed information about a user's friends.
  • getAppUsers (2) - Returns a list of IDs of the current user's friends who installed the application.
  • getByPhones (1) - Returns a list of the current user's friends whose phone numbers, validated or specified in a profile, are in a given list.
  • getLists (1) - Returns a list of the user's friend lists.
  • getMutual (2) - Returns a list of user IDs of the mutual friends of two users.
  • getOnline (2) - Returns a list of user IDs of a user's friends who are online.
  • getRecent (2) - Returns a list of user IDs of the current user's recently added friends.
  • getRequests (1) - Returns information about the current user's incoming and outgoing friend requests.
  • getSuggestions (1) - Returns a list of profiles of users whom the current user may know. For the method to return enough suggestions, method account.importContacts will be called first.
  • search (2) - Returns a list of friends matching the search criteria.

See more at VK API: Friends

[ to top | to menu ]

Likes

Access rights required: wall.

  • add (1) - Adds the specified object to the Likes list of the current user.
  • delete (1) - Deletes the specified object from the Likes list of the current user.
  • getList (2) - Returns a list of IDs of users who added the specified object to their Likes list.
  • isLiked (2) - Checks for the object in the Likes list of the specified user.

See more at VK API: Likes

[ to top | to menu ]

(1) This method can be called with a user token received in Standalone-app via Implicit Flow.

(2) This method can be called with a user token.

(3) This method can be called with a service token.

(4) This method can be called with a community token.

Support

You can donate via PayPal, Yandex Money, WebMoney (Z124862854284, R343524258966) and Patreon

[ to top | to menu ]

Copyright and License

Vk was written by Andrey Helldar for the Laravel Framework 5.4 or later, and is licensed under MIT License.

[ to top | to menu ]

Translation

Translations of text and comment by Google Translate. Help with translation +1 in karma :)

Description of the VK API methods in the comments is taken from the VK API.

[ to top | to menu ]

About

Laravel package for VK API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.9%
  • HTML 0.1%