Andrei Freeman (lordandrei) wrote in lj_clients,
Andrei Freeman
lordandrei
lj_clients

  • Mood:

XMLRPC, Newbie take 2: Login returns odd fault

I've switched over to using the OS's built in XMLRPC deliver mechanism.

This has allowed me to successfully make a call to getChallenge.

Using the return data I've tried a login. This is returning a strange error:

"FaultCode" = -1; 
"FaultString" = "Can't use string (\"0\") as a HASH ref while \"strict refs\" in 
    use at /home/lj/cgi-bin/ljprotocol.pl line 2359.\n"; 


The code I'm trying is below. Please note, it is Cocoa for OSX.

Any advice would be warmly welcomed...

Thanks

  NSURL *aURL = [NSURL URLWithString:@"http://www.livejournal.com/interface/xmlrpc"];
  NSDictionary *result;
  NSDictionary *theChallenge = [self getChallenge];
  NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:4];
	
  NSString *theChallengeKey = [theChallenge objectForKey:@"challenge"];
  NSString *thePWHash = [@"XXXXXXXX" md5];  // My password
  NSString *theResponse = [[NSString stringWithFormat:@"%@%@", theChallengeKey, thePWHash] md5];
	
  [params setObject:@"XXXXXXXX" forKey:@"username"]; // My username
  [params setObject:@"challenge" forKey:@"auth_method"];
  [params setObject:theChallengeKey forKey:@"auth_challenge"];
  [params setObject:theResponse forKey:@"auth_response"];

  WSMethodInvocationRef inv = WSMethodInvocationCreate(
    (CFURLRef)aURL,
    (CFStringRef)@"LJ.XMLRPC.login",
    kWSXMLRPCProtocol);
	
  if(params != nil) {
    NSArray *order = [NSArray arrayWithObject: @"struct"];
    WSMethodInvocationSetParameters(inv, (CFDictionaryRef)params, (CFArrayRef)order);
  }
	
  CFDictionaryRef result = WSMethodInvocationInvoke(inv);

  if(WSMethodResultIsFault(result))
    NSLog([(NSDictionary *)result description]);

Subscribe
  • Post a new comment

    Error

    Comments allowed for members only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 1 comment