: : ?

     & API
    &   API
, , ... , - . , API .

:
<?PHP
/////////////////////////////////////////////////////////////////////////////
/// . mail.ru
///
/// http://api.mail.ru/sites/my/add/
/// 򠠠
/// http://api.mail.ru/docs/guides/restapi/
/////////////////////////////////////////////////////////////////////////////

// ;)
error_reporting(0);

////////////////////////////////////////////////////////////////////
$mailru_apps = ''; // ID
$mailru_secret = ''; //Secret Key
$mailru_derect = 'http://site.kz/authorization.php'; // URL GET
////////////////////////////////////////////////////////////////////

// GET
$codes = $_GET["code"];

// POST
$params = array(
"client_id" => $mailru_apps,
"client_secret" => $mailru_secret,
"grant_type" => "authorization_code",
"scope" => "stream",
"code" => $codes,
"redirect_uri" => $mailru_derect,
);
$post = http_build_query($params);;
$url = "https://connect.mail.ru/oauth/token";
$headers = array("POST /oauth/token HTTP/1.1
Host: connect.mail.ru
Accept: */*
Content-Length: ".strlen($post)."
Content-Type: application/x-www-form-urlencoded");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
curl_close($ch);

// JSON
$obj = json_decode($result);

//
$muid = $obj->{'x_mailru_vid'}; // ID
$sess_key = $obj->{'access_token'}; // access token (24 )
$refresh_token = $obj->{'refresh_token'}; // refresh token access token
$expires_in = $obj->{'expires_in'}; // access token

// SING
function sign_server_server(array $request_params, $secret_key) {
ksort($request_params);
$params = '';
foreach ($request_params as $key => $value) {
if ($key!='sig') {
$params .= "$key=$value";
}
}
return md5($params.$secret_key);
}

// users.getInfo
$params = array(
"format" => "xml", // xml or json
"method" => "users.getInfo",
"app_id" => $mailru_apps,
"session_key" => $sess_key,
"uids" => $muid,
"secure" => "1"
);

//
$url = "http://www.appsmail.ru/platform/api?".http_build_query($params)."&sig=".sign_server_server($params,$mailru_secret);
$response = file_get_contents($url);
$xmlc = simplexml_load_string($response);

//
echo 'birthday '.$xmlc->user->birthday.'<br>';
echo 'Email '.$xmlc->user->email.'<br>';
echo 'first name '.$xmlc->user->first_name.'<br>';
echo 'last name '.$xmlc->user->last_name.'<br>';
echo 'My link '.$xmlc->user->link.'<br>';
echo 'nick '.$xmlc->user->nick.'<br>';
echo 'Avatar '.$xmlc->user->pic.'<br>';
echo 'Big avatar '.$xmlc->user->pic_big.'<br>';
echo 'My id '.$xmlc->user->uid.'<br>';
echo 'sess_key '.$sess_key.'<br>';
echo 'refresh_token '.$refresh_token.'<br>';
echo 'code '.$codes.'<br>';

//
echo "<a href='https://connect.mail.ru/oauth/authorize?client_id={$mailru_apps}&response_type=code&scope=stream&redirect_uri={$mailru_derect}'></a>";

, , .

:
<?PHP
/////////////////////////////////////////////////////////////////////////////
/// . vk.com
/// 蠠
/// http://vk.com/editapp?act=create
/////////////////////////////////////////////////////////////////////////////

// ;)
error_reporting(0);

////////////////////////////////////////////////////////////////////
$vk_apps = ''; // ID
$vk_secret = ''; //Secret Key
$vk_scope= 'notify,offline,wall,friends,photos'; //
$vk_derect = 'http://site.kz/authorization.php'; // URL GET
////////////////////////////////////////////////////////////////////

//
$url = "https://oauth.vkontakte.ru/access_token?client_id={$vk_apps}&client_secret={$vk_secret}&code=".$_GET['code'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

// JSON
$obj_vk = json_decode($out);

//
$sid = $obj_vk->{'access_token'}; // access token
$id = $obj_vk->{'user_id'}; // ID

// API
class vkapi {
var $api_secret;
var $app_id;
var $api_url;
function vkapi($app_id, $api_secret, $api_url = 'api.vk.com/api.php') {
$this->app_id = $app_id;
$this->api_secret = $api_secret;
if (!strstr($api_url, 'http://')) $api_url = 'http://'.$api_url;
$this->api_url = $api_url;
}
function api($method,$params=false, $fields) {
if (!$params) $params = array();
$params['api_id'] = $this->app_id;
$params['v'] = '3.0';
$params['method'] = $method;
$params['timestamp'] = time();
$params['format'] = 'xml'; //xml or json
$params['random'] = rand(0,10000);
//////////////////////////////////
if($fields){
//
$params['fields'] = $fields;
}
//////////////////////////////////
ksort($params);
$sig = '';
foreach($params as $k=>$v) {
$sig .= $k.'='.$v;
}
$sig .= $this->api_secret;
$params['sig'] = md5($sig);
$query = $this->api_url.'?'.$this->params($params);
$res = file_get_contents($query);
return $res;
}
function params($params) {
$pice = array();
foreach($params as $k=>$v) {
$pice[] = $k.'='.urlencode($v);
}
return implode('&',$pice);
}
}

//
$VK = new vkapi($vk_apps, $vk_secret);

//
$data_user = $VK->api('getProfiles', array('uids'=>$id));
$xml_data = simplexml_load_string($data_user);

//
echo 'access_token '.$sid;
echo '<br>';
echo 'ID '.$xml_data->user->uid;
echo '<br>';
echo 'Name '.$xml_data->user->first_name;
echo '<br>';
echo 'last name '.$xml_data->user->last_name;
echo '<br>';

// ( = http://vk.com/developers.php?oid=-1&p=users.get )
$additionally = $VK->api('users.get', array('uids'=>$id), 'photo_medium');
$xml_additionally = simplexml_load_string($additionally);

//
echo 'Photo '.$xml_additionally->user->photo_medium;
echo '<br>';

//
echo '<a href="http://oauth.vkontakte.ru/authorize?client_id='.$vk_apps.'&scope='.$vk_scope.'&redirect_uri='.$vk_derect.'&response_type=code">Autch site</a>';

, , ...


: »   |   : kirill   |   : 7316
: 7
: 0
ICQ: 649540764
- 44 +
  : max95   |   :   |   : 10 2012  
: 7
: 0
ICQ: --
- 2 +
  : DarkGrek   |   :   |   : 10 2012  
)) )) facebook =)
: 95
: 2
ICQ: 656527
- 355 +
  : NGS   |   : NGS Engine   |   : 10 2012  
Loginza, )
: 47
: 0
ICQ: 602930609
- 51 +
  : zorro   |   :   |   : 10 2012  
wink
: 64
: 8
ICQ: 959098
- 82 +
  : kirill   |   :   |   : 10 2012  
NGS, ?))
)
: 107
: 2
ICQ: --
- 105 +
  : ZICKFREED   |   :   |   : 10 2012  
, ?
: 64
: 8
ICQ: 959098
- 82 +
  : kirill   |   :   |   : 10 2012  
ZICKFREED, , , + smile

, .
: 240
: 6
ICQ: 573235722
- -896 +
  : VELIK505   |   :   |   : 10 2012  
: 95
: 2
ICQ: 656527
- 355 +
  : NGS   |   : NGS Engine   |   : 11 2012  
VELIK505 () ?
: 64
: 8
ICQ: 959098
- 82 +
  : kirill   |   :   |   : 11 2012  
NGS,
: 4
: 0
ICQ: --
- 2 +
  : Anton-writer   |   :   |   : 13 2012  
-! ! winked
: 138
: 2
ICQ: 567777707
- 490 +
  : Forceman   |   :   |   : 16 2012  
Twitter.
: 7
: 0
ICQ: --
- 4 +
  : advertwm   |   :   |   : 17 2012  
. , , , , .)
: 138
: 2
ICQ: 567777707
- 490 +
  : Forceman   |   :   |   : 17 2012  
. .
: 59
: 2
ICQ: 207679
- 143 +
  : Scrin   |   :   |   : 21 2012  
- )
: 138
: 2
ICQ: 567777707
- 490 +
  : Forceman   |   :   |   : 21 2012  
! .
: 59
: 2
ICQ: 207679
- 143 +
  : Scrin   |   :   |   : 24 2012  
: Forceman
! .

? )
: 138
: 2
ICQ: 567777707
- 490 +
  : Forceman   |   :   |   : 25 2012  
? )


. .
, .

_
: 59
: 2
ICQ: 207679
- 143 +
  : Scrin   |   :   |   : 26 2012  
: Forceman
. .
, .

, ...
: 159
: 10
ICQ: 407464816
- 174 +
  : bizze   |   : V.I.P.   |   : 02 2012  
, , : , - .
: 64
: 8
ICQ: 959098
- 82 +
  : kirill   |   :   |   : 09 2012  
bizze, ! ) () ))
: 159
: 10
ICQ: 407464816
- 174 +
  : bizze   |   : V.I.P.   |   : 22 2012  
kirill,
, - , , , . , . , . , , "" . , , , , , .
: kirill
() ))

? ? , , .
: 64
: 8
ICQ: 959098
- 82 +
  : kirill   |   :   |   : 22 2012  
bizze, * , , , * , , ""


, , .