我正在尝试使用php获取Windows实时连接。我用ws获得js sdk但不是用PHP。 这是我的代码:
$CLIENT_ID =variable_get('example_contact_grabber_hotmail_client_id',NULL);
$REDIRECT_URL = variable_get('example_contact_grabber_hotmail_url_callback',NULL);
//dpm($REDIRECT_URL);
$url = "https://oauth.live.com/authorize?client_id=$CLIENT_ID&scope=wl.signin&response_type=code&redirect_uri=$REDIRECT_URL";
$url = str_replace( "&", "&", urldecode(trim($url)) );
//dpm($url);
$ch = curl_init($url);
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, TRUE);
$salida = curl_exec($ch);
curl_close($ch);
$todo = split("\n",$salida);
//dpm($todo);
请求给我这条消息。
Array
(
[0] => <html><head><title>Object moved</title></head><body>
[1] => <h2>Object moved to <a href="https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&checkda=1&ct=1329999219&rver=6.1.6208.0&wp=MBI_SSL&wreply=https:%2F%2Foauth.live.com%2Fauthorize%3Fclient_id%3D000000004008DFE4%26scope%3Dwl.signin%26response_type%3Dcode%26redirect_uri%3Dhttp:%2F%2Fpruebas.eneomed.es%2Flivesdk%2FSamples%2FPHP%2FOauthSample%2Fcallback.php%26auth_redirect%3Dtrue&lc=1033&id=276649&popupui=1">here</a>.</h2>
[2] => </body></html>
[3] =>
)
如果我在Firefox中查看$url
,那就没事了。
答案 0 :(得分:0)
尝试添加:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//And change
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //true to false
希望有所帮助