Bible Forum

The Bible NETWork ~ Impacting the World for Christ one post at a time!

It is currently Fri May 24, 2013 7:04 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Sat Aug 27, 2011 11:18 am 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
Hi - I saw that one of the return types for your API is jsonp, which made me hopeful that your API supported using dojo.io.script, however when I tried it, it appears that your API does not return a call to the callback function created by Dojo. Are you planning support for dojo.io.script, by any chance? If not, what would you recommend I do in order to call your API from JavaScript?

Thanks and blessings!
Lee


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 12:39 pm 
Offline
tech-admin

Joined: Wed Jul 12, 2006 2:43 pm
Posts: 136
Faith: Christian
Ecclesiology/Denomination: Baptist
Because the API supports JSONP, anything that also supports JSONP can use it. I've never used dojo.io.script before, but, based on their documentation, http://dojotoolkit.org/reference-guide/ ... properties you need to set "callbackParamName" to the name of the GET parameter that the web service expects to contain name of the callback function. In this case, that is "callback"

So, once again based on the doc, you would make a request like this:

Code:
dojo.io.script.get({
   url: "http://labs.bible.org/api/",
   callbackParamName: "callback",
   content: {
      passage: "John 3:16" // Or whatever passage you want to fetch
   }
});


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 1:22 pm 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
Hi, Brian- thanks for the quick response!

That's exactly what I thought I should do - except for the fact that the JSONP example (http://labs.bible.org/api/?passage=John ... myfunction) shows the callback function name to be "myfunction". When I switch the name to "callback", as you suggest, my code now works - thanks so much!

Lee


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 1:38 pm 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
Lee wrote:
Hi, Brian- thanks for the quick response!

That's exactly what I thought I should do - except for the fact that the JSONP example (http://labs.bible.org/api/?passage=John ... myfunction) shows the callback function name to be "myfunction". When I switch the name to "callback", as you suggest, my code now works - thanks so much!

Lee


I should clarify: everything I've read indicates that the callbackParamName should contain the name of the callback function as given by the provider - hence I used "myfunction"...


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 1:45 pm 
Offline
tech-admin

Joined: Wed Jul 12, 2006 2:43 pm
Posts: 136
Faith: Christian
Ecclesiology/Denomination: Baptist
Ah ok, I'm just curious though: where did you read this? Because that isn't what the documentation says: callbackParamName: The URL parameter name that indicates the JSONP callback string. http://dojotoolkit.org/reference-guide/ ... properties

So, the callbackParamName is the name of the parameter, not the value. The "myfunction" in the example on the Labs page, http://labs.bible.org/api_web_service is just a place holder - I've added some text to help that be less opaque.


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 2:20 pm 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
Ha - I discovered that I only have one source for this - the other sites were quoting :-)

Search for the 2nd use of callbackParamName in http://ofps.oreilly.com/titles/97805965 ... ation.html (Dojo - The Definitive Guide).


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 5:23 pm 
Offline
tech-admin

Joined: Wed Jul 12, 2006 2:43 pm
Posts: 136
Faith: Christian
Ecclesiology/Denomination: Baptist
Quote:
To clarify, the callbackParamName specifies the name of the query string parameter that is established by example.com. It is not the name of a function you've defined to act as a callback yourself.


Did you get it to work? And, how are you using the API? We always like to hear about what people are doing with it! :)

Brian


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 5:46 pm 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
briansea wrote:
Quote:
To clarify, the callbackParamName specifies the name of the query string parameter that is established by example.com. It is not the name of a function you've defined to act as a callback yourself.


Did you get it to work? And, how are you using the API? We always like to hear about what people are doing with it! :)

Brian


Right... So in my case, example.com is you guys - so if I look at your sample on http://labs.bible.org/api_web_service, i.e.:
Quote:
http://labs.bible.org/api/?passage=John%203:16&type=json&callback=myfunction

my conclusion is going to be that callbackParamName parameter in my code should be myfunction.

I see what you added by way of explanation on the API page, but unless I'm missing something (and I've definitely been known to miss things in the past :-), your explanation is stating the opposite of what you quoted. I don't actually have a callback function. Dojo creates one dynamically which incorporates the name specified in callbackParamName.

Yes it works! Eventually I want to build an app to aid in learning memory verses, and I was just looking around for a way to easily pull verses into my app rather than relying on cut & paste. For now I'm just playing around with both the technology (Javascript in general, Dojo in particular) and looking for sites with multiple translations of the Bible which support API calls. So far I've found you and Biblia.com (Biblia.com offers more translations, but I like the way you format the returned JSON better).


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 6:16 pm 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
Two additional points:
- The URL I pasted in from your sample page actually works - so that would seem to me to bolster my conclusion that myfunction is what I want to use for callbackParamName.
- In my other test, which I based on the example at Biblia.com, I was also having trouble - then on a whim I switched to use callback there as well for the value of callbackParamName (instead of myCallbackFunction, which, again, was what worked in their example), and I was able to successfully use their API as well.


Top
 Profile  
 
PostPosted: Sat Aug 27, 2011 6:41 pm 
Offline
tech-admin

Joined: Wed Jul 12, 2006 2:43 pm
Posts: 136
Faith: Christian
Ecclesiology/Denomination: Baptist
Hopefully this will help to clear up the confusion.

The example URL on labs is: http://labs.bible.org/api/?passage=John ... myfunction
It has: callback=myfunction

So, the GET parameter in which you send the name of your callback function is callback. We could have made it anything, but that is what our service expects. Based on the Biblia.com API doc, their callback parameter is also named callback. http://api.biblia.com/docs/Output_Format

myfunction refers to the name of the javascript function to which the result of the call will be passed. In the output from the example call, you can see that the function being called is indeed myfunction. : myfunction([{"bookname":"John","chapter":"3","verse":"16","text":"For this is the

You can also see that as you change the value of the callback parameter, that function call also changes in the response.

Quote:
my conclusion is going to be that callbackParamName parameter in my code should be myfunction.

I see what you added by way of explanation on the API page, but unless I'm missing something (and I've definitely been known to miss things in the past :-), your explanation is stating the opposite of what you quoted. I don't actually have a callback function. Dojo creates one dynamically which incorporates the name specified in callbackParamName.


The problem here is one of terms and abstraction, I think. The name of the parameter is not the name of the callback function. The name of the paramater (callbackParamName) is the name of the GET parameter in which you pass the name of the callback function.

At any rate, I'm glad you got both APIs to work! Scripture memory is a great goal and use! :)

Brian


Top
 Profile  
 
PostPosted: Tue Aug 30, 2011 1:06 pm 
Offline

Joined: Sat Aug 27, 2011 11:07 am
Posts: 7
Faith: Christian
Ecclesiology/Denomination: Non-denominational
Name of your church: West Hills Community Church
Brian - I don't think that doing a simple GET via the browser is the same thing, otherwise anything I passed in for callbackParamName would work, just as it does from the browser... Hence I'm not so sure about your terms/abstraction explanation - but regardless, my code works now :-)

Yes, scripture memorization is a wonderful thing - I can't tell you how many times prolonged meditation (even over years) on a given passage which I've memorized has yielded new and fresh insight. I hope I can build something useful toward that end!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group