XML-RPC and WebServices
XML-RPC and WebServices
- Subject: XML-RPC and WebServices
- From: Joel Watson <email@hidden>
- Date: Mon, 9 Feb 2004 21:32:42 -0800
Hi everyone!
I've been tinkering around with XML-RPC and WebServices attempting to
create a rudimentary blog-posting app that posts to blogger.com. I've
correctly set up all various WS calls such that I can successfully use
their blogger.getUsersBlogs and blogger.getUserInfo method from the
Blogger API. Unfortunately, I can't seem to get either the
blogger.newPost or blogger.editPost method to work. It seems to crash
at CFDictionaryRef resultDict = WSMethodInvocationInvoke(request);
which makes me think I have the parameters set up incorrectly, but I've
triple checked them and they're right. Anyone have any ideas? Here's
what I've got:
void newPost(CFStringRef content)
{
WSMethodInvocationRef request;
CFStringRef blogAddress =
CFSTR("
http://plant.blogger.com/api/RPC2");
CFStringRef methodName = CFSTR("blogger.newPost");
CFStringRef protocol = kWSXMLRPCProtocol;
CFStringRef param1key = CFSTR("appkey");
CFStringRef param1value = CFSTR("<insertactualappkeyhere>");
CFStringRef param2key = CFSTR("blogid");
CFStringRef param2value = CFSTR("<insertactualblogidhere>");
CFStringRef param3key = CFSTR("username");
CFStringRef param3value = CFSTR("<insertusernamehere>");
CFStringRef param4key = CFSTR("password");
CFStringRef param4value = CFSTR("<insertpasswordhere>");
CFStringRef param5key = CFSTR("content");
CFStringRef param5value = content;
CFStringRef param6key = CFSTR("publish");
CFBooleanRef param6value = TRUE;
CFMutableArrayRef order;
CFMutableDictionaryRef dict;
// Create the dictionary that will contain the parameters
dict = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
// Add the parameters to dict
CFDictionaryAddValue(dict, param1key, param1value);
CFDictionaryAddValue(dict, param2key, param2value);
CFDictionaryAddValue(dict, param3key, param3value);
CFDictionaryAddValue(dict, param4key, param4value);
CFDictionaryAddValue(dict, param5key, param5value);
CFDictionaryAddValue(dict, param6key, param6value);
// Create the array that the parameter order is stored in
order = CFArrayCreateMutable(NULL, 0, NULL);
// Add the parameters to designate their order
CFArrayAppendValue(order, param1key);
CFArrayAppendValue(order, param2key);
CFArrayAppendValue(order, param3key);
CFArrayAppendValue(order, param4key);
CFArrayAppendValue(order, param5key);
CFArrayAppendValue(order, param6key);
// Create the url object
CFURLRef url = CFURLCreateWithString(NULL, blogAddress, NULL);
// Create the request invocation
request = WSMethodInvocationCreate(url, methodName, protocol);
// Set the parameters of request
WSMethodInvocationSetParameters(request, dict, order);
// Send the request invocation and store its result in resultDict
CFDictionaryRef resultDict = WSMethodInvocationInvoke(request);
if( WSMethodResultIsFault(resultDict) ) {
CFTypeRef faultString = CFDictionaryGetValue(resultDict,
kWSFaultString);
CFShow(faultString);
}
else {
CFTypeRef myResult = CFDictionaryGetValue(resultDict,
kWSMethodInvocationResult);
CFShow(myResult);
CFShow(CFSTR("Item posted!"));
}
}
Any help would be greatly appreciated.
-Joel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.