Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > CoreFoundation, WebServices & the Blogger API

CoreFoundation, WebServices & the Blogger API
Thread Tools
Junior Member
Join Date: Jan 2001
Location: California, USA
Status: Offline
Reply With Quote
Feb 11, 2004, 03:00 PM
 
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
Reply With Quote
Feb 11, 2004, 05:22 PM
 
You know it makes sense. ☼ ☼ ☼ Growl.
     
Joel  (op)
Junior Member
Join Date: Jan 2001
Location: California, USA
Status: Offline
Reply With Quote
Feb 11, 2004, 08:35 PM
 
Originally posted by Diggory Laycock:
How about WSMakeStubs and

http://www.dev1.eraserver.net/WebServices/Blogger/
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
Reply With Quote
Feb 12, 2004, 06:23 AM
 
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
You know it makes sense. ☼ ☼ ☼ Growl.
     
Joel  (op)
Junior Member
Join Date: Jan 2001
Location: California, USA
Status: Offline
Reply With Quote
Feb 12, 2004, 09:23 AM
 
Originally posted by Diggory Laycock:
see also here:

http://www.macdevcenter.com/pub/a/ma...ne.html?page=2
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
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:59 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2