How to use Public API?
I came across a jQuery lightbox plug-in called PrettyPhoto. Seems very interesting. At the bottom of documentation I noticed a section about Public API, which I paste in its entirety below:
Version 2.5 introduced an easy to use API. You can now open prettyPhoto from anywere. The public API functions are the following:
$.prettyPhoto.open('images/fullscreen/image.jpg','Title','Description');
$.prettyPhoto.changePage('next');
$.prettyPhoto.changePage('previous');
$.prettyPhoto.close();
You can also open galleries using the API, just pass arrays to the open function.
images = ['images/fullscreen/image1.jpg','images/fullscreen/image2.jpg','images/fullscreen/image3.jpg'];
titles = ['Title 1','Title 2','Title 3'];
descriptions = ['Description 1','Description 2','Description 3']
$.prettyPhoto.open(images,title开发者_如何转开发s,descriptions);
You can now open prettyPhoto from Flash or launch is from anywhere, anytime!
Great! I want to try it, but I have never dealt with APIs and have no idea how and where to plug the API code provided.
Can I create some sort of widget that will allow people placing it on other sites and open pictures there from my site? I'm lost. Google search did not yield any demos of its implementations.
Any nudge in the write direction will be highly appreciated.
This is Javascript, so you need to write some Javascript code that interacts with the PrettyPhoto object. Usually PrettyPhoto works semi-automagically, you just initialize it with a number of options and it'll find links on the current page and act only when the user clicks on these links. Using the API you can get it to display images or move between images on your command though (i.e. you can write Javascript code that commands PrettyPhoto). "API" here just means "a bunch of public functions you can call." It should work as shown in the example, verbatim.
API stands for Application programming interface.
Every application that supports an API has it's own custom implementation. On your specific case PrettyPhoto
made an API than can be used calling those very same functions you pasted on your code.
Here's a solution to launch prettyPhoto
from Flash :
精彩评论