@@ 8-55 (lines=48) @@ | ||
5 | /** |
|
6 | * VK.con or Vkontakte is the most popular social network in Russia and some other countries. |
|
7 | */ |
|
8 | class Vk extends ProviderBase implements ProviderInterface |
|
9 | { |
|
10 | /** |
|
11 | * {@inheritdoc} |
|
12 | */ |
|
13 | public function shareUrl() |
|
14 | { |
|
15 | return $this->buildUrl('http://vk.com/share.php', |
|
16 | array( |
|
17 | 'url', |
|
18 | 'title', |
|
19 | 'image', |
|
20 | ) |
|
21 | ); |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * {@inheritdoc} |
|
26 | */ |
|
27 | public function shareCountRequest() |
|
28 | { |
|
29 | static::request( |
|
30 | $this->buildUrl( |
|
31 | 'https://vk.com/share.php', |
|
32 | array('url'), |
|
33 | array('act' => 'count') |
|
34 | ) |
|
35 | ); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * {@inheritdoc} |
|
40 | */ |
|
41 | public function shareCount($response) |
|
42 | { |
|
43 | // This returns something like: |
|
44 | // VK.Share.count(0, 59); |
|
45 | $counts = explode(',', $response); |
|
46 | ||
47 | if (!isset($counts[1])) { |
|
48 | return 0; |
|
49 | } |
|
50 | ||
51 | $count = trim($counts[1]); // it's now "59);", |
|
52 | ||
53 | return (int) $count; |
|
54 | } |
|
55 | } |
|
56 |
@@ 5-52 (lines=48) @@ | ||
2 | ||
3 | namespace SocialLinks\Providers; |
|
4 | ||
5 | class Xing extends ProviderBase implements ProviderInterface |
|
6 | { |
|
7 | /** |
|
8 | * {@inheritdoc} |
|
9 | */ |
|
10 | public function shareUrl() |
|
11 | { |
|
12 | ||
13 | /* |
|
14 | * alternate request url: |
|
15 | * https://www.xing-share.com/app/user?op=share;sc_p=xing-share;url=YOUR-URL |
|
16 | */ |
|
17 | ||
18 | return $this->buildUrl( |
|
19 | 'https://www.xing.com/spi/shares/new', |
|
20 | array( |
|
21 | 'url', |
|
22 | ) |
|
23 | ); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * {@inheritdoc} |
|
28 | */ |
|
29 | public function shareCountRequest() |
|
30 | { |
|
31 | $url = $this->buildUrl( |
|
32 | 'https://www.xing-share.com/app/share', |
|
33 | array('url'), |
|
34 | array( |
|
35 | 'op' => 'get_share_button', |
|
36 | 'counter' => 'top', |
|
37 | ) |
|
38 | ); |
|
39 | ||
40 | return static::request($url); |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * {@inheritdoc} |
|
45 | */ |
|
46 | public function shareCount($response) |
|
47 | { |
|
48 | preg_match('/xing-count(.+?)(\d+)(.*?)<\/span>/i', $response, $matches); |
|
49 | ||
50 | return empty($matches[2]) ? 0 : (int) $matches[2]; |
|
51 | } |
|
52 | } |
|
53 |