Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
i am developing module for importing the contact from Hotmail .
i found some code on google but this code in php so can any one convert following php code in asp.net?

PHP
<?php
//***************************************MSN START********************************
$client_id = 'CLIENT_ID';
$client_secret = 'SECRET_KEY';
$redirect_uri = 'http://www.yourdomain.com/oauth-hotmail.php';
$urls_ = 'https://login.live.com/oauth20_authorize.srf?client_id='.$client_id.'&scope=wl.signin%20wl.basic%20wl.emails%20wl.contacts_emails&response_type=code&redirect_uri='.$redirect_uri;
$msn_link =  '<a href="'.$urls_.'" >MSN Contacts</a>';
echo $msn_link;
//***************************************MSN ENDS********************************
?>



PHP
<?php
//function for parsing the curl request
function curl_file_get_contents($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$client_id = 'CLIENT_ID';
$client_secret = 'SECRET_KEY';
$redirect_uri = 'http://www.yourdomain.com/oauth-hotmail.php';
$auth_code = $_GET["code"];
$fields=array(
'code'=>  urlencode($auth_code),
'client_id'=>  urlencode($client_id),
'client_secret'=>  urlencode($client_secret),
'redirect_uri'=>  urlencode($redirect_uri),
'grant_type'=>  urlencode('authorization_code')
);
$post = '';
foreach($fields as $key=>$value) { $post .= $key.'='.$value.'&'; }
$post = rtrim($post,'&');
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,'https://login.live.com/oauth20_token.srf');
curl_setopt($curl,CURLOPT_POST,5);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
$result = curl_exec($curl);
curl_close($curl);
$response =  json_decode($result);
$accesstoken = $response->access_token;
$url = 'https://apis.live.net/v5.0/me/contacts?access_token='.$accesstoken.'&limit=100';
$xmlresponse =  curl_file_get_contents($url);
$xml = json_decode($xmlresponse, true);
$msn_email = "";
foreach($xml['data'] as $emails)
{
// echo $emails['name'];
$email_ids = implode(",",array_unique($emails['emails'])); //will get more email primary,sec etc with comma separate
$msn_email .= "<div><span>".$emails['name']."</span> &nbsp;&nbsp;&nbsp;<span>". rtrim($email_ids,",")."</span></div>";
}
echo $msn_email;

?>
Posted

http://www.asp.net/downloads/archived-v11/migration-assistants/php-to-aspnet[^]

This is a Converter, But there will be not proper conversion from any of this type convertors. Better to find ASP.net code rather than converting.
 
Share this answer
 
v2
Did you see this link ? It has provided importing contacts from Hotmail. Try following steps they have provided and map with your solution.

http://import-contacts.blogspot.in/2011/11/import-contacts-from-gmail-yahoo.html[^]
 
Share this answer
 
Comments
Gihan Liyanage 15-Sep-14 6:16am    
Did you got a solution from my support, I can see you have not accepted any answer.If you are ok with this answer plz accept it. Then any user having same problem can identified it has solved the problem..
Hi Gihan Liyanage , yes i already used it but not able to import Hotmail contact.
i fount This http://www.walkswithme.net/hotmail-contact-list-reader-api-in-php-msn-oauth[^] php code for importing contact.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900