Hi Ankit,
Based on the error you're getting, try putting your OAuth params in the request header.
I was able to successfull update my status using this PHP:
require('yosdk/lib/OAuth.php');//OAuth lib ships w/ Y! PHP SDK
//key secret for client/desktop app
$key = '{key}';
$secret = '{secret}';
$consumer = new OAuthConsumer($key, $secret);//defined in OAuth lib
$accessToken = json_decode(file_get_contents('accessToken.txt'));//assuming you already have access token
$guid = '{guid of app user}';
$url = sprintf(
"http://%s/v1/user/%s/presence/presence",
'social.yahooapis.com',
$guid
);
//sign request
$request = OAuthRequest::from_consumer_and_token(//defined in OAuth lib
$consumer,
$accessToken,
'PUT',
$url,
array());
$request->sign_request(
new OAuthSignatureMethod_HMAC_SHA1(),
$consumer,
$accessToken
);
//define headers
$headers = array("Accept: application/json");
$headers[] = $request->to_header();
$headers[] = "Content-type: application/json";
//define new status and format it for request
$status = 'and the time is ... '.time();
$presence = array("status" => $status);
$content = json_encode($presence);
//exec request
$ch = curl_init($url);
$options = array(
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $content,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_TIMEOUT => 3
);
curl_setopt_array($ch, $options);
$resp = curl_exec($ch);
curl_close($ch);
For future reference, please indicate what language you're using, if you're building a desktop or web app, if you're using the Y! SDK, and some sample code that reproduces the problem.
Please post back if you have any further questions.
Erik
Hi
I was able to use all Social APIs including GET STATUS API. But for setting the status, when i use PUT Method, it says please provide valid credentials.
Kindly explain what could be the problem. I'm passing all the Oauth Parameters required but still don't know why it's not working.
Kindly suggest
THANKS
ANKIT