New version submitted by TomB
[carbonphp.git] / Documentation / libraries / flickr.html
blob647506b26ac9925a3a6934812ca733a12773454e
1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
2 <head>
3 <title>CarbonPHP Documentation</title>
4 <style type="text/css">
5 * {
6 margin: 0;
7 padding: 0;
10 html {
11 font-family: "Lucida Sans Unicode", "Lucida Grande";
12 font-size: 12px;
15 body {
16 background: #fff;
17 color: #666;
20 h1 {
21 font-size: 15px;
22 font-weight: bold;
23 margin: 0 0 5px 0;
26 h2 {
27 font-size: 13px;
28 font-weight: bold;
29 margin: 5px 0 5px 0;
32 ol, ul {
33 margin: 10px 0 10px 0;
34 list-style-position: inside;
37 p {
38 margin: 5px 0 5px 0;
41 .content {
42 border: 1px dotted #444;
43 margin: 10px;
44 padding: 10px;
45 text-align: justify;
46 width: 700px;
49 .example {
50 border: 1px solid #ccc;
51 background: #eee;
52 margin: 10px;
53 padding: 10px;
55 </style>
56 </head>
58 <body>
59 <div class="content">
60 <h1>Flickr API Library</h1>
62 <p>The Flickr API library allows you to easily use the Flickr API. You initialise the library using the
63 following line and the object will be available as <b>$this->flickr</b>.</p>
65 <div class="example">
66 $this->load->library('flickr');
67 </div>
69 <p>You can also pass configuration parameters as an array in the second parameter of the method.</p>
71 <div class="exmaple">
72 $this->load->library('flickr', array('api_key' => 'yourapikeyhere', 'api_secret' => 'yourapisecrethere'));
73 </div>
74 </div>
76 <div class="content">
77 <h1>Calling a Flickr API Method</h1>
79 <p>You can use the <b>$this->flickr->call_method()</b> method to call a Flickr API method.</p>
81 <div class="example">
82 $this->flickr->call_method('flickr.test.echo', array('foo' => 'bar', 'carbon' => 'php'));
83 </div>
85 <p>The above code will call the <b>flickr.test.echo</b> method and will return an XML response. If the call fails
86 the <b>$this->flickr->call_method()</b> will return -1, and you can call the following two methods to get the error code
87 and message.</p>
89 <div class="example">
90 echo $this->flickr->get_error_code();<br />
91 echo $this->flickr->get_error_message();</br />
92 </div>
94 <p>If the method call is successful you will get an XML representation in an object (simple XML). You can then parse this
95 reponse. The reponse to our above method call will look something like the following response.</p>
97 <div class="example">
98 &lt;rsp stat="ok"&gt;<br />
99 &nbsp;&nbsp;&nbsp;&nbsp;&lt;method&gt;flickr.test.echo&lt;/method&gt;<br />
100 &nbsp;&nbsp;&nbsp;&nbsp;&lt;api_key&gt;apikeywillbehere&lt;/api_key&gt;<br />
101 &nbsp;&nbsp;&nbsp;&nbsp;&lt;foo&gt;bar&lt;/foo&gt;<br />
102 &nbsp;&nbsp;&nbsp;&nbsp;&lt;carbon&gt;php&lt;/carbon&gt;<br />
103 &lt;/rsp&gt;
104 </div>
105 </div>
107 <div class="content">
108 <h1>Calling Methods that Require Authentication</h1>
110 <p>Some methods require that the user be authenticated to Flickr. When you register your web application you
111 can specify a callback URL that Flickr will redirect the user to once they are authenticated. To create the URL the
112 user must visit to authenticate the use of your web application is shown in the following code.</p>
114 <div class="example">
115 echo $this->flickr->get_auth_url('read');
116 </div>
118 <p>This will create an authentication URL that will grant your web application read permissions to the users
119 Flickr profile.</p>
121 <p>There are three permissions you can set they are shown below.</p>
123 <ul>
124 <li>read - grants the permission to read private information</li>
125 <li>write - grants the permission to add, edit, delete photo metadata, this includes 'read'</li>
126 <li>delete - grants the permission to delete photos, this includes 'write' and 'read'</li>
127 </ul>
129 <p>Once authenticated you can store the frob token, and use this to get a token to call the authenticated
130 methods.</p>
131 </div>
132 </body>
134 </html>