问题
I am using this example to successfuly make a login connection on windows live platform:
http://code.msdn.microsoft.com/messengerconnect
(the oauth handler callback one)
I receive a token and a user id from their api, but I can't seem to understand how to fetch the user profile from these info.
Does anyone know how to do this?
There are examples in MS website, but they are all C# or javascript ones and I have to do it in PHP.
After retrieving the token and the cid I tried this, but returns me an error:
$url_string = 'http://apis.live.net/V4.1/cid-'.$user->getId().'/Profiles/';
echo("<br/>\n".$url_string);
$curl_session = curl_init($url_string);
// build HTTP header with authorization code
$curl_options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Authorization: WRAP access_token=AuthToken="'.urlencode($_REQUEST['stoken']).'"',
'Accept: application/json'
)
);
// setup options for curl transfer
curl_setopt_array($curl_session, $curl_options);
// execute session and get response
$curl_response = curl_exec($curl_session);
print $curl_response;
curl_close($curl_session);
The error is this:
{"Title":"ErrorResource","Code":1062,"Message":"Request does not contain a valid PUID."}
can you guys help me retrieving the user info?
EDIT:
solved the problem by removing the =AuthToken from the authorization and it worked!
Thanks,
Joe
回答1:
Yes!
made it work after hours trying lots of differents samples from ms ¬¬
the problem was the Authorization: WRAP access_token=AuthToken=
just removed the AuthToken= and it worked!
so its now like this:
'Authorization: WRAP access_token="'.$wrapper->getReturnedParameter('wrap_access_token').'"'
来源:https://stackoverflow.com/questions/4526808/retrieving-user-profile-on-messengerwindows-live-connect-sdk-within-php