21-06-2015, 08:20
|
|
|
חבר מתאריך: 03.01.12
הודעות: 149
|
|
Yahoo API
מה המצב חברה
אני מנסה לקבל מ YAHOO טוקן
הקוד מנסה לגשת דרך CURL ל oauth2/get_token
ואני נזרק על ידי
error:Failed to connect to api.login.yahoo.com port 443: Connection timed out
זה הקוד אשמח לעזרה תודה
קוד PHP:
$client_id = 'dj0yJmk9Y2YxaGl0YVpFRUFLJmQ9WVdrOWVGQk1kMVZDTlRZb WNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1jOQ--';
$client_secret = 'aad6379296a28280ee44f5325dbe70081e361b16';
if(isset($_GET['code']))
{
//$params['client_id'] = $client_id;
//$params['client_secret'] = $client_secret;
$params['grant_type'] = 'authorization_code';
$params['redirect_uri'] = urlencode(base_url('api/yahoo'));
$params['code'] = $_GET['code'];
/*
$req_data = '';
foreach($params as $key=>$value) { $req_data .= $key.'='.$value.'&'; }
$req_data = rtrim($req_data,'&');
*/
$headers = base64_encode($client_id).':'.base64_encode($clien t_secret);
$yahoo_t = 'https://api.login.yahoo.com/oauth2/get_token';
$ch = curl_init($yahoo_t);
curl_setopt($ch, CURLOPT_USERPWD, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic realm="'.$headers.'"'
));
$contacts_json = curl_exec($ch);
if(curl_errno($ch))
{
echo 'error:' . curl_error($ch);
}
var_dump(curl_getinfo($ch));
curl_close($ch);
var_dump($contacts_json);
}
else
{
$req_data = '?client_id='.$client_id;
$req_data .= '&redirect_uri='.urlencode(base_url('api/yahoo'));
$req_data .= '&response_type=code';
$yahoo_a = 'https://api.login.yahoo.com/oauth2/request_auth'.$req_data;
redirect($yahoo_a, 'refresh', 302);
}
|