phpFlickr Class 3.0
Written by Dan Coulter (dancoulter@users.sourceforge.net)
Project Homepage: http://www.phpflickr.com/
Google Code Project Page: http://code.google.com/p/phpflickr/
Released under GNU Lesser General Public License (http://www.gnu.org/copyleft/lgpl.html)
For more information about the class and upcoming tools and applications using it,
visit http://www.phpflickr.com/ or http://code.google.com/p/phpflickr/
If you are interested in hiring me for a project (involving phpFlickr
or not), feel free to email me.
Installation instructions:
1. Copy the files from the installation package into a folder on your
server. They need to be readible by your web server. You can put
them into an include folder defined in your php.ini file, if you
like, though it's not required.
2. All you have to do now is include the file in your PHP scripts and
create an instance. For example:
$f = new phpFlickr();
The constructor has three arguments:
A. $api_key - This is the API key given to you by flickr.com. This
argument is required and you can get an API Key at:
http://www.flickr.com/services/api/key.gne
B. $secret - The "secret" is optional because is not required to
make unauthenticated calls, but is absolutely required for the
new authentication API (see Authentication section below). You
will get one assigned alongside your api key.
C. $die_on_error - This takes a boolean value and determines
whether the class will die (aka cease operation) if the API
returns an error statement. It defaults to false. Every method
will return false if the API returns an error. You can access
error messages using the getErrorCode() and getErrorMsg()
methods.
3. All of the API methods have been implemented in my class. You can
see a full list and documentation here:
http://www.flickr.com/services/api/
To call a method, remove the "flickr." part of the name and replace
any periods with underscores. For example, instead of
flickr.photos.search, you would call $f->photos_search() or instead
of flickr.photos.licenses.getInfo, you would call
$f->photos_licenses_getInfo() (yes, it is case sensitive).
All functions have their arguments implemented in the list order on
their documentation page (a link to which is included with each
method in the phpFlickr clasS). The only exceptions to this are
photos_search(), photos_getWithoutGeodata() and
photos_getWithoutGeodata() which have so many optional arguments
that it's easier for everyone if you just have to pass an
associative array of arguments. See the comment in the
photos_search() definition in phpFlickr.php for more information.
Authentication:
As of this release of the phpFlickr class there is only one authentication method
available to the API. This method is somewhat complex, but is far more secure and
allows your users to feel a little safer authenticating to your application. You'll
no longer have to ask for their username and password.
Authentication API - http://www.flickr.com/services/api/auth.spec.html
I know how complicated this API looks at first glance, so I've tried to
make this as transparent to the coding process. I'll go through the steps
you'll need to use this. Both the auth.php and getToken.php file will
need your API Key and Secret entered before you can use them.
To have end users authenticate their accounts:
First, setup a callback script. I've included a callback script that
is pretty flexible. You'll find it in the package entitled "auth.php".
You'll need to go to flickr and point your api key to this file as the
callback script. Once you've done this, on any page that you want to
require the end user end user to authenticate their flickr account to
your app, just call the phpFlickr::auth() function with whatever
permission you need to use.
For example:
$f->auth("write");
The three permissions are "read", "write" and "delete". The function
defaults to "read", if you leave it blank.
Calling this function will send the user's browser to Flickr's page to
authenticate to your app. Once they have logged in, it will bounce
them back to your callback script which will redirect back to the
original page that you called the auth() function from after setting
a session variable to save their authentication token. If that session
variable exists, calling the auth() function will return the permissions
that the user granted your app on the Flickr page instead of redirecting
to an external page.
To authenticate the app to your account to show your private pictures (for example)
This method will allow you to have the app authenticate to one specific
account, no matter who views your website. This is useful to display
private photos or photosets (among other things).
*Note*: The method below is a little hard to understand, so I've setup a tool
to help you through this: http://www.phpflickr.com/tools/auth/.
First, you'll have to setup a callback script with Flickr. Once you've
done that, edit line 12 of the included getToken.php file to reflect
which permissions you'll need for the app. Then browse to the page.
Once you've authorized the app with Flickr, it'll send you back to that
page which will give you a token which will look something like this:
1234-567890abcdef1234
Go to the file where you are creating an instance of phpFlickr (I suggest
an include file) and after you've created it set the token to use:
$f->setToken("<token string>");
This token never expires, so you don't have to worry about having to
login periodically.
Using Caching:
Caching can be very important to a project. Just a few calls to the Flickr API
can take long enough to bore your average web user (depending on the calls you
are making). I've built in caching that will access either a database or files
in your filesystem. To enable caching, use the phpFlickr::enableCache() function.
This function requires at least two arguments. The first will be the type of
cache you're using (either "db" or "fs")
1. If you're using database caching, you'll need to supply a PEAR::DB connection
string. For example:
$flickr->enableCache("db", "mysql://user:password@server/database");
The third (optional) argument is expiration of the cache in seconds (defaults
to 600). The fourth (optional) argument is the table where you want to store
the cache. This defaults to flickr_cache and will attempt to create the table
if it does not already exist.
2. If you're using filesystem caching, you'll need to supply a folder where the
web server has write access. For example:
$flickr->enableCache("fs", "/var/www/phpFlickrCache");
The third (optional) argument is, the same as in the Database caching, an
expiration in seconds for the cache.
Note: filesystem caching will probably be slower than database caching. I
haven't done any tests of this, but if you get large amounts of calls, the
process of cleaning out old calls may get hard on your server.
You may not want to allow the world to view the files that are created during
caching.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Cosmetico-v1.0_weidea.net_BootstrapWordpress前端源码模板_网站UI界面主题.zip (527个子文件)
style.css 137KB
font-awesome-ie7.css 48KB
font-awesome-ie7.min.css 47KB
woo.css 34KB
jquery-ui-1.10.3.custom.css 32KB
jquery-ui-1.10.3.custom.min.css 30KB
jquery-ui.css 27KB
font-awesome.css 27KB
video-js.css 25KB
font-awesome.min.css 24KB
prettyPhoto.css 21KB
video-js.min.css 20KB
aqpb-view.css 12KB
responsive.css 11KB
uniform.default.css 10KB
aqpb.css 10KB
aqpb_blocks.css 5KB
supersized.shutter.css 5KB
anythingslider.css 3KB
supersized.css 2KB
admin.css 1KB
supersized.core.css 1KB
adipoli.css 407B
under_construction.css 198B
text-editor.css 72B
drop_ie.css 53B
fontawesome-webfont.eot 37KB
progress.gif 7KB
loader.gif 7KB
loader.gif 6KB
progress.gif 3KB
loader.gif 2KB
loader.gif 2KB
loader.gif 2KB
loader.gif 2KB
loader.gif 2KB
animated-overlay.gif 2KB
animated-overlay.gif 2KB
default_thumbnail.gif 227B
default_thumbnail.gif 227B
default_thumbnail.gif 227B
default_thumbnail.gif 227B
default_thumbnail.gif 227B
xit.gif 146B
cross.gif 83B
arrow.gif 66B
PIE.htc 40KB
documentation.html 57KB
documentation.html 56KB
demo.html 2KB
index.html 0B
favicon.ico 1KB
slider-bg.jpg 143KB
footer_bg.jpg 64KB
cat-bg.jpg 42KB
nhbg.jpg 12KB
thbg.jpg 11KB
test_bg.jpg 10KB
bwhg.jpg 9KB
bg.jpg 9KB
menu_bg_selected.jpg 8KB
tbhbg.jpg 8KB
menu_bg.jpg 8KB
test_bg2.jpg 2KB
jquery-ui.min.js 223KB
video.js 142KB
jquery.min.js 89KB
jquery-1.6.2.min.js 89KB
video.min.js 62KB
jquery.custom-scrollbar.js 56KB
jquery.anythingslider.js 39KB
jquery.touchslider.js 35KB
supersized.3.2.7.js 35KB
jscolor.js 26KB
cb_button.js 26KB
jquery.prettyPhoto.js 22KB
jquery.knob.js 21KB
jquery.adipoli.js 20KB
jquery.uniform.js 19KB
supersized.3.2.7.min.js 18KB
jquery.anythingslider.video.js 16KB
aqpb.js 16KB
jquery.anythingslider.min.js 15KB
supersized.shutter.js 12KB
swfobject.js 10KB
supersized.core.3.2.1.js 10KB
jquery.uniform.min.js 9KB
jquery.easing.1.3.js 8KB
jquery.adipoli.min.js 8KB
jquery.anythingslider.fx.js 8KB
supersized.shutter.min.js 7KB
jquery.easing.min.js 7KB
jquery.anythingslider.video.min.js 6KB
upl.js 5KB
jquery.masonry.min.js 5KB
supersized.core.3.2.1.min.js 4KB
jquery.backstretch.min.js 4KB
aqpb-fields.js 4KB
jquery.anythingslider.fx.min.js 3KB
jquery.easing.1.2.js 3KB
共 527 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
dunming_6725413
- 粉丝: 16
- 资源: 6950
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功