Ocean West Posted July 11, 2011 Posted July 11, 2011 using SMA i am currently registering two functions. xPathParse() and GetURLasText(), I have about a dozen FM CF and they all pretty much do the same thing. However I am wondering if I could consolidate all my functions in to one plugin and include the two registered functions. This is to talk directly to MailChimp API to return xml results The first call is on startup to call a function to register or store your API key provided. you will also need the data center value which is the last 3 characters of the API key. exmaple: 0cxxef03xxx16ca5e1d09c524xxxc6acbx50-us2 Right now I have a settings table with that data in a field. The second call is to retrieve a value a list name and ID and store that in the settings table. I store also as a global variable. $$mc_id d189932607737 Sample List The the functions calls would pass in a parameter depending on the method section you are issuing listInterestGroupAdd and with that the optional parameters of the URL string could change. AddGroup ( groupName ) Let ( [ $$mc_url = "http://"& Right( $$mc_api ;3) & ".api.mailchimp.com/1.3/?method=listInterestGroupAdd&apikey="& $$mc_api &"&id="& $$mc_id &"&group_name="& groupName &"&output=xml" ; $$mc_result = GetURLasText( $$mc_url ) ];"") the URL structure is pretty much the same for each method the end result would be to retrieve the actual URL and the XML results perhaps as two separate functions. returnURL returnXML or if there is a better method using the Mail Chimp API the I would be all ears! http://apidocs.mailchimp.com/
dansmith65 Posted July 11, 2011 Posted July 11, 2011 I didn't look at the mailchip api; this message assumes you would continue using web services to interact with mailchimp. You will need some sort of persistent storage method in the plug-in, so that you can save your API key in the plug-in on start-up. Unless you want to hard-code your API key in the plug-in, but I wouldn't assume you want to do that. I know of two types of persistent storage for ScriptMaster plug-in's: using an expando, or using compiled classes with static properties. If you do a search on this forum for expando or persistent storage, you should be able to find some examples of the first method. I started an open source project that utilizes classes with static properties, you could use it as a framework to write your own plug-in: https://github.com/dansmith65/ooScriptMaster With that, I think you should be able to simplify it down to these custom functions: Initialize() - store API key RetrieveId() - I don't quite understand what this does, I'm just taking your word for it that you need it. this is the part that would retrieve a value, list name, and ID GetGroup(groupName) - construct URL, get URL as text fyi: there is a simpler way to get a URL as text. It may not be better than the example that comes with ScriptMaster, but it is much simpler. new URL(urlString).getText()
Ocean West Posted July 11, 2011 Author Posted July 11, 2011 when you say you are getting URL as text is it actually getting the URL string or the contents as text of the resolved page? In my case the example i am after is the latter where SM will grab what ever text the url returns such as XML in this case. but also having a function to return the built URL so you could test it in a browser.
dansmith65 Posted July 11, 2011 Posted July 11, 2011 It is getting the response from the server. I have been using it with Google Distance Matrix API and it works well. GroovyDoc .toString() will return the built URL for testing in a browser. JavaDoc
Recommended Posts
This topic is 4895 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now