Thanks for quick reply. I want to add contact with email addresses. I tried the following code.
require_once ('http.php');
require_once ('oauth_client.php');
$client = new oauth_client_class;
$client->server = 'Microsoft';
$client->redirect_uri = 'my redirect url';
$url = 'my site url';
$client->client_id = 'client id from hotmail';
$application_line = __LINE__;
$client->client_secret = 'client secret from hotmail';
if(strlen($client->client_id) == 0 || strlen($client->client_secret) == 0)
die('Please go to Microsoft Live Connect Developer Center page '.
'https://manage.dev.live.com/AddApplication.aspx and create a new'.
'application, and in the line '.$application_line.' set the client_id to Client ID and client_secret with Client secret. '.'The callback URL must be '.$client->redirect_uri.' but make sure '.'the domain is valid and can be resolved by a public DNS.');
$client->scope = 'wl.contacts_create';
$add_contacts = array('first_name' => 'Sohel',
'last_name' => 'Rana',
'name' => 'Sohel Rana',
'birth_day' => 21,
'birth_month' => 9,
'emails' => array(
'preferred' => '
[email protected]',
'account' => '
[email protected]')
);
if(($success = $client->Initialize()))
{
if(($success = $client->Process()))
{
if(strlen($client->authorization_error))
{
$client->error = $client->authorization_error;
$success = false;
}
elseif(strlen($client->access_token))
{
$success = $client->CallAPI('https://apis.live.net/v5.0/me/contacts', 'POST', $add_contacts, array('FailOnAccessError'=>true), $user);
}
}
$success = $client->Finalize($success);
}
if($client->exit)
{
exit;
}
if($success)
{
print_r($success);
}