 |
 |
CoreFoundation, WebServices & the Blogger API
|
 |
|
 |
|
Junior Member
Join Date: Jan 2001
Location: California, USA
Status:
Offline
|
|
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:
Code:
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, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
// 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, &kCFTypeArrayCallBacks);
// 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!"));
}
}
I've run this by a couple mailing lists to no avail. Any help would be greatly apprecciated!
-Joel
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Jan 2001
Location: California, USA
Status:
Offline
|
|
Hm.. That's interesting. I used WSMakeStubs and successfully made it produce a set of four files for me:
WSGeneratedObj.h
WSGeneratedObj.m
WSStub.h
WSStub.m
Unfortunately, I couldn't make heads or tails out of what was going on in there. Is there somewhere that explains this a little bit better? There were redeclarations and such in the WSStub files that made no sense. The only reference I found to it in the docs goes as follows:
WSDL Support
Currently the first release of Web Services does not include a WDSL API. A tool is available at /Developer/Tools/WSMakeStubs to generate static stubs. This tool parses the WSDL and produces templates for C++, Objective-C, and AppleScript. Various degrees of complexity are available in the generated stubs. The stub adheres to “Section 5” encoding and simple marshalling.
This wasn't very helpful. Thanks for your help thus far!
-Joel
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
I think you generated Obj-C classes there:
I'm not familiar with Carbon - which is what I assume you're using - perhaps you want to create C++ objects instead.
Code:
Widebook:~ diggory$ /developer/tools/WSMakeStubs
/developer/tools/WSMakeStubs [-x lang] [-dir directory] [-name fname] { -url <url> | -file <file> }
Generates stubs for use with WebServices.framework. One of -url or -file must be specified.
-x: the development language to use
-dir: a path to the output directory where the stubs will be generated.
If not specified, defaults to the current working directory
-name: the name to be used for the root of the output file. An
appropriate extension will be added to the file[s]. The default
name is WSStub.
-url: url to a valid WSDL file
-file: path to a valid WSDL file in the filesystem. If this is '-', the
file is read from stdin
Available language emitters: (c++ is the default)
c++: CoreFoundation with C++ bindings. Additionally creates
WSGeneratedStub.{cp.h}
ObjC: CoreFoundation with Objective-C bindings. Additionally
creates WSGeneratedObj.{m,h}
applescript: AppleScript
Tool version 0.2 (smz)
Widebook:~ diggory$
see also here:
http://www.macdevcenter.com/pub/a/ma...ne.html?page=2
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Jan 2001
Location: California, USA
Status:
Offline
|
|
Ah! That should be quite helpful. Look as I may, I couldn't find any sort of tutorial on this except for the Web Services section in the CoreFoundation Objective-C docs (which were spotty at best). Thanks! The only reason I was using CoreFoundation was because that's the only way I could find to access it aside from Ranchero Software's XML-RPC cocoa library (and I'd prefer to learn Apple's library if at all possible). I would much rather develop it in Cocoa and Objective-C.
-Joel
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|