|
Sohel Rana - 2014-01-22 14:25:50
can you give an example, how can i add contact with more than one emails using post method.
Manuel Lemos - 2014-01-23 03:57:13 - In reply to message 1 from Sohel Rana
What API are you talking about? Google? Facebook? What?
Sohel Rana - 2014-01-23 05:16:03 - In reply to message 2 from Manuel Lemos
I am taking about hotmail API. Can you provide a tutorial. Thanks in advance.
I send a POST request with data in a method called CALLAPI but it only insert
name and birthday not emails and address. I found a class for hotmail, in that class has CALLAPI method. Its working on GET request for reading contacts
Manuel Lemos - 2014-01-23 05:42:23 - In reply to message 3 from Sohel Rana
Do you want to add a contact with email addresses or do you want to get the contacts with email addresses?
What is the code you are using to call the CallAPI function?
Sohel Rana - 2014-01-23 08:15:59 - In reply to message 4 from Manuel Lemos
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' => 'sohel_adust@yahoo.com',
'account' => 'test@test.com')
);
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);
}
Manuel Lemos - 2014-01-23 09:45:03 - In reply to message 5 from Sohel Rana
In that case you need to send a JSON object setting the request content type to application/json. Also make sure that you set at least the personal email address. The others are optional.
$parameters = array(
'first_name' => 'Sohel',
'last_name' => 'Rana',
'name' => 'Sohel Rana',
'birth_day' => 21,
'birth_month' => 9,
'emails' => array(
'personal' => 'sohel_adust@yahoo.com',
)
);
$success = $client->CallAPI(
'https://apis.live.net/v5.0/me/contacts',
'POST', $parameters, array(
'RequestContentType'=>'application/json',
'FailOnAccessError'=>true), $user);
Sohel Rana - 2014-01-23 10:02:57 - In reply to message 6 from Manuel Lemos
Thanks a lot man, you save my huge time.
Sohel Rana - 2014-03-31 05:57:23 - In reply to message 7 from Sohel Rana
Hi, I got much helpful tutorial from phpclasses. Now i stuck on a problem from last one week. Yahoo contact API does not return any contact. I use oauth 2.0 for authentication. Please give me some helpful solution. Thanks in advance.
Manuel Lemos - 2014-03-31 07:20:55 - In reply to message 8 from Sohel Rana
The class built-in Yahoo support uses OAuth 1.0a. Did you try with OAuth 1.0a?
|