Question

I am trying to consume delicious api in adobe AIR AS3 project described here: https://github.com/avos/delicious-api

particularly the suggest api (/v1/posts/suggest) described at the end of this page: https://github.com/avos/delicious-api/blob/master/api/posts.md

In debug mode the app asks for username and password and keeps asking it even after providing valid username and password and never tracing the response. I have no idea what's going wrong here. Below is my code:

var request:URLRequest = new URLRequest("https://api.del.icio.us/v1/posts/suggest?red=api&url=http%3A%2F%2Fyahoo.com");
request.method = URLRequestMethod.POST;

//encoded string using as3 class at https://github.com/MoritzStefaner/revisit/blob/master/lib/com/hurlant/util/Base64.as
var encoded:String = Base64.encode("validusername:validpassword");
trace(encoded);
var credsHeader:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + encoded);
request.requestHeaders.push(credsHeader);
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, handleResults);
loader.load(request);

function handleResults(evt:Event):void
{
    var response:String = evt.target.data as String;
    trace("response:" + response);
}

No correct solution

OTHER TIPS

From taking a brief look at the linked API, none of the methods suggest support for authentication information being sent as part of the POST body (which is what your code is doing). So unless that is documented somewhere else, you are using the API incorrectly. It's also reasonably rare to see an HTTP POST combined with a QueryString (which is again what your code above is doing) so that is a little odd.

I think Delicious just needs HTTP Basic auth, which is covered in an SO question here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top