{"id":15017591,"url":"https://github.com/getjump/vkapiphp","last_synced_at":"2025-04-04T16:16:52.944Z","repository":{"id":16663185,"uuid":"19418792","full_name":"getjump/VkApiPHP","owner":"getjump","description":"[Abandoned] Library for work with API Vk.com","archived":false,"fork":false,"pushed_at":"2022-04-25T18:09:45.000Z","size":125,"stargazers_count":200,"open_issues_count":17,"forks_count":53,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-03-28T15:11:12.920Z","etag":null,"topics":["api","php","vk","vkontakte"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getjump.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-04T04:24:12.000Z","updated_at":"2025-03-05T03:20:06.000Z","dependencies_parsed_at":"2022-09-01T04:01:35.378Z","dependency_job_id":null,"html_url":"https://github.com/getjump/VkApiPHP","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getjump%2FVkApiPHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getjump%2FVkApiPHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getjump%2FVkApiPHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getjump%2FVkApiPHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getjump","download_url":"https://codeload.github.com/getjump/VkApiPHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208190,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","php","vk","vkontakte"],"created_at":"2024-09-24T19:50:43.462Z","updated_at":"2025-04-04T16:16:52.920Z","avatar_url":"https://github.com/getjump.png","language":"PHP","readme":"# Vk API PHP\n\n[![Build Status](https://travis-ci.org/getjump/VkApiPHP.svg?branch=master)](https://travis-ci.org/getjump/VkApiPHP)\n[![Code Style Status](https://styleci.io/repos/19418792/shield)](https://styleci.io/repos/19418792)\n\nThat library will help you organize your work with API Vk.com\n\n## Installation\n\nYou can get library and all of it dependencies through [composer](https://getcomposer.org/)\n\n`composer require \"getjump/vk:*\"`\n\n## Explanation\n\nOkay, that is how we can instantiate main object for our future requests\n\n```php\n$vk = getjump\\Vk\\Core::getInstance()-\u003eapiVersion('5.5')-\u003esetToken(\u003e\u003e\u003e HERE YOUR TOKENS GOES \u003c\u003c\u003c);\n```\n\n\u003eYOU CAN GET SOME TOKENS AT : \n\u003eYou can get some tokens at:\n\u003ehttp://oauth.vk.com/authorize?client_id=3470411\u0026scope=messages,photos,groups,status,wall,offline\u0026redirect_uri=blank.html\u0026display=page\u0026v=5.5\u0026response_type=token\n\u003eI can't steal them, since it's VK side stuff guys, scope means what rights you needed for, i recommend as much as you can, if you don't want problems.\nIf you wanna use site authorization, look at next snippet:\n\n```php\n$vk = getjump\\Vk\\Core::getInstance()-\u003eapiVersion('5.5');\n\n$auth = getjump\\Vk\\Auth::getInstance();\n$auth-\u003esetAppId('3470411')-\u003esetScope('SCOPE')-\u003esetSecret('SECRET CODE')-\u003esetRedirectUri('http://localhost/test.php'); // SETTING ENV\n$token=$auth-\u003estartCallback(); // Here we will have token, if everything okay\n\nprintf(\"\u003ca href='%s' target='_top'\u003eLINK\u003c/a\u003e\", $auth-\u003egetUrl());\nif($token) {\n    $vk-\u003esetToken($token);\n    $vk-\u003erequest('users.get', ['user_ids' =\u003e range(1, 100)])-\u003eeach(function($i, $v) {\n        if($v-\u003elast_name == '') return;\n        print $v-\u003elast_name . '\u003cbr\u003e';\n    });\n}\n```\n\nI already did some wrappers just for you, if you wanna more, please do and pull request but you still can don't use them, or use something like this.\n\n```php\n$vk-\u003erequest('friends.get', ['user_id' =\u003e '15157875'])-\u003eeach(function($i, $v) {});\n```\n\nThat us long polling shiet, it works like a hell, as fast as you can see.\n```php\n// Long pooling loop\n$lp = new getjump\\Vk\\Wrapper\\LongPoll($vk);\n$lp-\u003edoLoop();\n```\n\nWe will do badass stuff, like kiss. You can do like the following and it will works\n```php\n//KISS\n$user=new getjump\\Vk\\Wrapper\\User(getjump\\Vk\\Core::getInstance()-\u003eapiVersion('5.5'));\n$user-\u003eget(1, 'photo_max_orig, sex'); //It will contain RequestTransaction, and will wait for your action, like getting response -\u003eresponse or calling -\u003eeach(callback)\n//Since __get and __call are overrided, we will request for a data, only when it neeeded\n```\n\nWe can use my own sakhalin technilogies and take all the stuff that VK have for that request using generators\n```php\n// Friends gets\n$friends = new getjump\\Vk\\Wrapper\\Friends($vk);\nforeach($friends-\u003eget(15157875, 'first_name, last_name')-\u003ebatch(100) as $f) //BATCH MEAN $f WILL CONTAIN JUST 100 ELEMENTS, AND REQUEST WILL MADE FOR 100 ELEMENTS\n{\n    /**\n     * @var $f \\getjump\\Vk\\ApiResponse;\n     */\n \n    $f-\u003eresponse-\u003eeach(function($i, $j) {\n        if(!$j-\u003eonline) return;\n        print $j-\u003egetName() . '\u003cbr\u003e';\n    });\n}\n```\n\nBut you still can do old style stuff\n```php\n //SECOND OPTION TO JUST GET EVERYTHING, WITHOUT count BEING SEND\n$friends-\u003eget(15157875, 'first_name, last_name')-\u003eresponse-\u003eeach(function($i, $d) {\n     if($d-\u003eonline)\n     {\n         print $d-\u003egetName() . '\u003cbr\u003e';\n     }\n});\n```\n\nThat snippet will show you your last 200 messages\n```php\n//MESSAGES\n$data = $vk-\u003erequest('messages.get', ['count' =\u003e 200]);\n \n$userMap = [];\n$userCache = [];\n \n$user = new \\getjump\\Vk\\Wrapper\\User($vk);\n \n$fetchData = function($id) use($user, \u0026$userMap, \u0026$userCache)\n{\n    if(!isset($userMap[$id]))\n    {\n        $userMap[$id] = sizeof($userCache);\n        $userCache[] = $user-\u003eget($id)-\u003eresponse-\u003eget();\n    }\n \n    return $userCache[$userMap[$id]];\n};\n\n//REQUEST WILL ISSUE JUST HERE! SINCE __get overrided\n$data-\u003eeach(function($key, $value) use($fetchData) {\n    $user = $fetchData($value-\u003euser_id);\n    printf(\"[%s] %s \u003cbr\u003e\", $user-\u003egetName(), $value-\u003ebody);\n    return;\n});\n```\n\nOnce more black magic. VK has method called execute, that can take something like JS code. Look what i've done for that.\n```php\n$js1 = $vk-\u003erequest('messages.get', ['count' =\u003e 200, 'offset' =\u003e0 * 200])-\u003etoJs(); //IT WILL RETURN VkJs object\n$js2 = $vk-\u003erequest('messages.get', ['count' =\u003e 200, 'offset' =\u003e1 * 200])-\u003etoJs();\n$js3 = $vk-\u003erequest('messages.get', ['count' =\u003e 200, 'offset' =\u003e2 * 200])-\u003etoJs();\n$js4 = $vk-\u003erequest('messages.get', ['count' =\u003e 200, 'offset' =\u003e3 * 200])-\u003etoJs();\n\n\n$js1\n        -\u003eappend($js2) // WE ARE APPENDING js2 to js1\n        -\u003eappend($js3)\n        -\u003eappend($js4) \n        -\u003eexecute() // WE WANT EXECUTE THIS (actually it will return RequestTransaction)\n        -\u003eresponse //AS FOR NOW WE REALLY DO SOME REQUEST TO API \n        -\u003eeach(\n            function($i, $v) //FIRST CALLBACK IS NEEDED TO GO FOR EVERY PART OF RESPONSE, ARRAY WITH 4-ELS IN OUR CASE\n            {\n                $v-\u003eeach(function($c, $d) { // SECOND TO CHECK EVERY ELEMENTS IN ARRAY WITH 200 ELEMENTS\n                    if(isset($d-\u003ebody)) print $d-\u003ebody; //WE JUST OUTPUTTING MESSAGE IF IT SET\n                });\n            });\n            \n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetjump%2Fvkapiphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetjump%2Fvkapiphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetjump%2Fvkapiphp/lists"}