-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample.php
More file actions
49 lines (36 loc) · 1019 Bytes
/
example.php
File metadata and controls
49 lines (36 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Date: 13.08.16
* Time: 22:16
* @Author http://github.com/biganfa
*/
require_once "vendor/autoload.php";
echo "vk auth lib test\n";
/** this file is in .gitignore, you need to create it manually. Example
*
* const TEST_VK_LOGIN = '81234567890';
const TEST_VK_PATH = 'password';
*
* */
require_once "test_login_pass_constants.php";
$agent = new \VkAuth\VkAuthAgent(TEST_VK_LOGIN, TEST_VK_PATH, '/tmp/vk-auth.log', function ($message) {
echo $message . PHP_EOL;
});
$jar = $agent->getAuthorizedCookieJar();
$client = new GuzzleHttp\Client([
'base_uri' => 'http://vk.com',
'timeout' => 10,
]);
/** @var \GuzzleHttp\Psr7\Response $response */
$response = $client->get(
'/friends',
[
'allow_redirects' => true,
'cookies' => $jar // auth cookie inside
]
);
$vkResponseBody = strval($response->getBody());
$friends = preg_match_all('/si_owner(.+)<\/a>/', $vkResponseBody, $matches);
echo "\n friends: \n";
echo implode("\n", $matches[1]);
echo "done\n";