php postback_url http zhumarin ru api_test ok php client_id 204627456

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$postback_url = 'http://zhumarin.ru/api_test/ok.php';
$client_id = 204627456;
$client_secret = '0520CE3ABF3F44F3D041419D';
$application_key = 'CBAPFDDNABABABABA';
if (isset($_GET['code'])) {
$curl = curl_init('http://api.odnoklassniki.ru/oauth/token.do');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query(array(
'code' => $_GET['code'],
'redirect_uri' => $postback_url,
'grant_type' => 'authorization_code',
'client_id' => $client_id,
'client_secret' => $client_secret,
), '', '&')));
echo curl_exec($curl);
} else {
echo '<a href="http://www.odnoklassniki.ru/oauth/authorize?client_id='.$client_id.'&amp;scope=VALUABLE_ACCESS&amp;response_type=code&amp;redirect_uri='.urlencode($postback_url).'">OK</a>';
}