Reply to this topicStart new topic
PUT method in SET STATUS API, Problems. Valid Credentials
Jono
post Jan 26 2009, 11:02 PM
Post #1
Group: Members
Posts: 18



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
Go to the top of the page
 
+Quote Post
Erik
post Jan 27 2009, 03:29 PM
Post #2
Group: Yahoos
Posts: 48



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



QUOTE (Jono @ Jan 26 2009, 11:02 PM) *
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


This post has been edited by Erik: Jan 27 2009, 03:33 PM
Go to the top of the page
 
+Quote Post
Jono
post Feb 11 2009, 11:31 PM
Post #3
Group: Members
Posts: 18



Hi

im using JAVA..
It doesn't say signature_invalid when calling all other apis, then why it says it's invalid when PUT status is used?
Also can we use PLAINTEXT signature method in PUT status API
Go to the top of the page
 
+Quote Post
Jono
post Feb 12 2009, 12:11 AM
Post #4
Group: Members
Posts: 18



THIS IS REALLY STRANGE OF YAHOO!
only during status calls it asks for LINKED parameters, ie. parameters should be alphabetically arranged.
I used linked hash map and it worked.
It worked but now it is entering null value in my status.
WHAT Request PARAMETER do i have to add with my call to set the status text. Right now i'm adding 'status' parameter and it's not working.
Go to the top of the page
 
+Quote Post
Jono
post Feb 12 2009, 01:40 AM
Post #5
Group: Members
Posts: 18



what i understand is that we have to pass status in the jason format ..
DOUBTS:
1. Do i have to pass it with a seperate header.. if yes what are the name and values of this header. ?
2. exactly what thing i have to pass (like json or json encoded etc) ?
3. Can i pass it in the parameters itself ?
Go to the top of the page
 
+Quote Post
basictheory
post Feb 26 2009, 01:09 AM
Post #6
Group: Yahoos
Posts: 32



QUOTE (Jono @ Feb 12 2009, 01:40 AM) *
what i understand is that we have to pass status in the jason format ..
DOUBTS:
1. Do i have to pass it with a seperate header.. if yes what are the name and values of this header. ?
2. exactly what thing i have to pass (like json or json encoded etc) ?
3. Can i pass it in the parameters itself ?



The http body should contain a JSON string representing the status. It will not accept the status in the query string or in a header.

ie:

{"status":"myNewStatus"}
Go to the top of the page
 
+Quote Post
MaryS
post Mar 11 2009, 03:24 AM
Post #7
Group: Members
Posts: 3



I am using java oauth libraries to try and update the user status. My code works for "GET", so i end up with the user's status.
However, when i do a 'PUT', i get this exception

SEVERE: params: {<?xml version='1.0' encoding='utf-8'?>
<error xmlns='http://yahooapis.com/v1/base.rng'
xml:lang='en'>
<description>405 Method Not Allowed</description>
<detail>Method not allowed for this URI
</detail>
</error>
, HTTP response=HTTP/1.1 405 Method Not Allowed
Date: Wed, 11 Mar 2009 11:20:01 GMT
Content-Type: application/xml
Content-Language: en
Allow: OPTIONS, HEAD, GET, PUT
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Via: HTTP/1.1 r1.ycpi.uls.yahoo.net (YahooTrafficServer/1.17.9 [c s f ])
Server: YTS/1.17.9

<?xml version='1.0' encoding='utf-8'?>
<error xmlns='http://yahooapis.com/v1/base.rng'
xml:lang='en'>
<description>405 Method Not Allowed</description>
<detail>Method not allowed for this URI
</detail>
</error>
, URL=http://social.yahooapis.com/v1/user/J7MKWLXDJUPVFPSB43CX4URHCQ/presence/presence, HTTP status=405, HTTP request headers=POST /v1/user/J7MKWLXDJUPVFPSB43CX4URHCQ/presence/presence
User-Agent: Jakarta Commons-HttpClient/3.1
Host: social.yahooapis.com
Content-Length: 1179
Content-Type: application/x-www-form-urlencoded
}


I am passing the status data in as parameters along side the OAuth parameters into an OAuthMessage.

final Map<String, String> values = new LinkedHashMap<String, String>();
values.put("starttime", "2009-03-11T04:13:12Z");
values.put("endtime", "");
values.put("status", "doing nothing");

Can someone tell me where im going wrong?

thanks
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Mar 11 2009, 12:26 PM
Post #8
Group: Yahoos
Posts: 942



Hi MaryS,

Can you please post the chunk where you're setting the PUT method...I'm seeing some POST info there.

Jon

QUOTE (MaryS @ Mar 11 2009, 03:24 AM) *
I am using java oauth libraries to try and update the user status. My code works for "GET", so i end up with the user's status.
However, when i do a 'PUT', i get this exception

SEVERE: params: {<?xml version='1.0' encoding='utf-8'?>
<error xmlns='http://yahooapis.com/v1/base.rng'
xml:lang='en'>
<description>405 Method Not Allowed</description>
<detail>Method not allowed for this URI
</detail>
</error>
, HTTP response=HTTP/1.1 405 Method Not Allowed
Date: Wed, 11 Mar 2009 11:20:01 GMT
Content-Type: application/xml
Content-Language: en
Allow: OPTIONS, HEAD, GET, PUT
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Via: HTTP/1.1 r1.ycpi.uls.yahoo.net (YahooTrafficServer/1.17.9 [c s f ])
Server: YTS/1.17.9

<?xml version='1.0' encoding='utf-8'?>
<error xmlns='http://yahooapis.com/v1/base.rng'
xml:lang='en'>
<description>405 Method Not Allowed</description>
<detail>Method not allowed for this URI
</detail>
</error>
, URL=http://social.yahooapis.com/v1/user/J7MKWLXDJUPVFPSB43CX4URHCQ/presence/presence, HTTP status=405, HTTP request headers=POST /v1/user/J7MKWLXDJUPVFPSB43CX4URHCQ/presence/presence
User-Agent: Jakarta Commons-HttpClient/3.1
Host: social.yahooapis.com
Content-Length: 1179
Content-Type: application/x-www-form-urlencoded
}


I am passing the status data in as parameters along side the OAuth parameters into an OAuthMessage.

final Map<String, String> values = new LinkedHashMap<String, String>();
values.put("starttime", "2009-03-11T04:13:12Z");
values.put("endtime", "");
values.put("status", "doing nothing");

Can someone tell me where im going wrong?

thanks
Go to the top of the page
 
+Quote Post
MaryS
post Mar 12 2009, 02:32 AM
Post #9
Group: Members
Posts: 3



Hi here is a snippet of my code


final String sessionKey = credentials.getKey();
final String sessionSecret = credentials.getSecret();
final OAuthRequestConfiguration requestConfig = new OAuthRequestConfiguration(
"PUT", sessionKey, sessionSecret);
final String guid = credentials.getUserId();

String requestUri = "http://social.yahooapis.com/v1/user/{guid}/presence/presence";
requestUri = requestUri.replace("{guid}", guid);

final Map<String, String> values = new LinkedHashMap<String, String>();
values.put("starttime", "2009-03-11T04:13:12Z");
values.put("endtime", "");
values.put("status", "doing nothing");

log.info("Request URI: " + requestUri);

try {
final String rawResponse = OAuthRequestBroker.request(
providerConfig, requestConfig, requestUri, values);
return rawResponse;
} catch (Throwable ex) { }


QUOTE (Jon @ Mar 11 2009, 12:26 PM) *
Hi MaryS,

Can you please post the chunk where you're setting the PUT method...I'm seeing some POST info there.

Jon
Go to the top of the page
 
+Quote Post
MaryS
post Mar 13 2009, 01:22 AM
Post #10
Group: Members
Posts: 3



Ok i managed to update the status. The problem was the OAuth libraries, they
did not support the PUT operation. So i basically got the latest ones and it works.
However when i put my new status eg 'thello his is a new status', this updates, however
when i check my profile page it says '“hello%20this%20is%20a%20new%20status” .
it seems as though it is not decoded on the yahoo end?
any ideas?

QUOTE (MaryS @ Mar 12 2009, 02:32 AM) *
Hi here is a snippet of my code


final String sessionKey = credentials.getKey();
final String sessionSecret = credentials.getSecret();
final OAuthRequestConfiguration requestConfig = new OAuthRequestConfiguration(
"PUT", sessionKey, sessionSecret);
final String guid = credentials.getUserId();

String requestUri = "http://social.yahooapis.com/v1/user/{guid}/presence/presence";
requestUri = requestUri.replace("{guid}", guid);

final Map<String, String> values = new LinkedHashMap<String, String>();
values.put("starttime", "2009-03-11T04:13:12Z");
values.put("endtime", "");
values.put("status", "doing nothing");

log.info("Request URI: " + requestUri);

try {
final String rawResponse = OAuthRequestBroker.request(
providerConfig, requestConfig, requestUri, values);
return rawResponse;
} catch (Throwable ex) { }
Go to the top of the page
 
+Quote Post
Jonathan LeBlanc
post Mar 20 2009, 08:06 AM
Post #11
Group: Yahoos
Posts: 942



hmmm are you setting the content type for the request? In the case of the PHP SDK it's set to "application/json". If the exploration of the content type doesn't produce results, can you try adding HTML entities for the space (&nbsp;). I'm thinking that the string is being url encoded and then output as plain text (which should be the content type setting).

- Jon

QUOTE (MaryS @ Mar 13 2009, 01:22 AM) *
Ok i managed to update the status. The problem was the OAuth libraries, they
did not support the PUT operation. So i basically got the latest ones and it works.
However when i put my new status eg 'thello his is a new status', this updates, however
when i check my profile page it says '“hello%20this%20is%20a%20new%20status” .
it seems as though it is not decoded on the yahoo end?
any ideas?
Go to the top of the page
 
+Quote Post
« Next Oldest · Status · Next Newest »
 

Reply to this topicStart new topic

 



rss YDN Forum RSS feeds

YDN Content Copyright © 2010 Yahoo! Inc. All rights reserved. Copyright | Privacy Policy

Help us continue to improve the Yahoo! Developer Network - Send Your Suggestions