Getting Data from Del.icio.us
Getting Data from Del.icio.us
- Subject: Getting Data from Del.icio.us
- From: Colin Wheeler <email@hidden>
- Date: Wed, 13 Jun 2007 15:50:49 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello all,
I've started work on a open source del.icio.us client, starting out I
developed a simple foundation test tool to get things going. The
problem being that now practically all the time it doesn't work,
whereas it used to work 50% of the time in the past before I changed
the cache policy on the NSMutableURLRequest to
NSURLRequestReloadIgnoringCacheData. My problem though is that I keep
constantly getting back NSError code -1012
( NSURLErrorUserCancelledAuthentication ) which nowhere in my code am
I canceling authentication.
Does anybody know what might be going on here? or have any advice/
reccomendations? I've provided the source code of my test tool below.
Thanks in advance!
From Colin Wheeler
#import <Foundation/Foundation.h>
#import "RFQuietLog.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *userName = @"__YOUR_DELICIOUSACCTNAME_";
NSString *password = @"__YOUR_PASSWD_";
NSString *agent = @"(RedFlag/0.1 (Mac OS X; http://
redflagproject.blogspot.com)";
NSString *header = @"User-Agent";
NSString *apiUrl = @"https://api.del.icio.us/v1/posts/update";
QuietLog(@"Starting to contact Del.icio.us...");
NSMutableURLRequest *urlRequest = [NSMutableURLRequest
requestWithURL:[NSURL URLWithString:apiUrl]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30];
[urlRequest setValue:agent forHTTPHeaderField:header];
NSURLResponse *urlResponse = [[NSURLResponse alloc] init];
NSError *urlError = [[NSError alloc] init];
NSURLCredential *userCredentials = [NSURLCredential
credentialWithUser:userName
password:password
persistence:NSURLCredentialPersistencePermanent];
NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc]
initWithHost:@"https://api.del.icio.us"
port:443
protocol:@"https"
realm:@"del.icio.us API"
authenticationMethod:@"NSURLAuthenticationMethodDefault"];
[[NSURLCredentialStorage sharedCredentialStorage]
setCredential:userCredentials
forProtectionSpace:space];
NSData *returnData = [[NSData alloc] initWithData:[NSURLConnection
sendSynchronousRequest:urlRequest
returningResponse:&urlResponse
error:&urlError]];
if ([urlError code] != 0 ) {
QuietLog(@"ERROR: %@", urlError);
}
NSString *delString = [[NSString alloc] initWithData:returnData
encoding:NSUTF8StringEncoding];
if(!returnData || [returnData length] == 0){
QuietLog(@"Sorry had an error! Return Data is nil or has 0 bytes of
data!");
} else {
QuietLog(@"XMLString: %@",delString);
}
[returnData release];
[urlResponse release];
[urlError release];
[space release];
[pool release];
return 0;
}
btw the quietlog thing is a function shown on borkware, you can
replace QuietLog with NSLog
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iQIVAwUBRnBYsD01GYpyfpRUAQKSHRAAiR0DUhg4yVPmiF628orOQgR8tNv+WEN7
nD+3DDyOzYSsh2OVYTjdTLZXfmPcWTACW4YPbwYOZfZHBUcLQGf4GcgownzfK6Dw
m3GV3UAd0xCLh8fbSbsXop/WoygkNcw/LL/FjSPXVKSkBa1FAQte86aeywiS1v2o
XFxAX0uaQRsz4VypEi2j8O0euovf73mQlcrCUxsaEGqPvBHjuy6MIcPLcC40VdIc
WljWN1dH3Oqj+m8CwK0bVdIkn2eZ1r1kMkNojT7+bQzCsb2ChQss/aQ0IkV94dZr
T4N5mIlf/YJTQAuhD1RMzhv9bHQavdNfj56ev/IfTGyjBZdSDSUAZclsk3dj3sG+
GYSgIeJQw9h/xKZPCcInbb4f1zcnG7uwBoZhSa5VbMf+MkAwy4YS0iDaAmHBswyd
b/6W1pC6rjaf9WClvP9wXtvEAMjRe+6xTZpTymi2IaYSWcOZEt05hcp/AiI8ZfGY
//udzxS+IAj+IbIUC+PDNyNlPV344pkARN8Urdc9ay9hj0165it/hqZZBypqSEj/
Oi5xkd3UEb7P4LEeZN2/S8t8bWmACmbqNDYw3ea1wToTYNWYxsVwloe8wJ6DUbJQ
9aHMRAOXyHPMHE02SWdiBqSqZ/1P6mzBiUEVG3KTleLAtos97615iQLzcL4GPDzz
XWV0K1TENS4=
=3RN/
-----END PGP SIGNATURE-----
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden