forked from secrethash/trickster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.html
More file actions
635 lines (411 loc) · 26.5 KB
/
README.html
File metadata and controls
635 lines (411 loc) · 26.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>README</title>
<link rel="stylesheet" href="https://stackedit.io/res-min/themes/base.css" />
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body><div class="container"><h1 id="trickster">Trickster</h1>
<ul>
<li><a href="#trickster">Trickster</a> <br>
<ul><li><a href="#why-trickster">Why Trickster?</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#usage">Usage</a> <br>
<ul><li><a href="#1-service-provider">1. Service Provider</a></li>
<li><a href="#2-facade">2. Facade</a></li>
<li><a href="#3-configuration">3. Configuration</a></li>
<li><a href="#4-ready-steady-go">4. Ready, Steady, GO!</a></li></ul></li>
<li><a href="#tricksters-tricks">Trickster’s Tricks</a> <br>
<ul><li><a href="#1-truncator">1. Truncator</a></li>
<li><a href="#2-email-validator">2. Email Validator</a></li>
<li><a href="#3-slug-converter">3. Slug Converter</a></li>
<li><a href="#4-youtube-embed">4. YouTube Embed</a></li>
<li><a href="#5-gravatar-grabber">5. Gravatar Grabber</a></li>
<li><a href="#6-extension-splitter">6. Extension Splitter</a></li>
<li><a href="#7-simple-social-analytics">7. Simple Social Analytics</a></li>
<li><a href="#8-bb-code-engine">8. BB Code Engine</a></li>
<li><a href="#9-tags-sweeper">9. Tags Sweeper</a></li>
<li><a href="#10-time-ago">10. Time Ago</a></li>
<li><a href="#11-cipher">11. Cipher</a></li>
<li><a href="#12-vimeo-video-embed">12. Vimeo Video Embed</a></li>
<li><a href="#13-video-info-grabber">13. Video Info Grabber</a></li>
<li><a href="#14-wikipedia-grabber">14. Wikipedia Grabber</a></li>
<li><a href="#15-url-shortener">15. URL Shortener</a></li>
<li><a href="#16-suggest">16. Suggest</a></li>
<li><a href="#17-ip-grabber">17. IP Grabber</a></li>
<li><a href="#18-currency-converter">18. Currency Converter</a></li></ul></li></ul></li>
</ul>
<h2 id="why-trickster">Why Trickster?</h2>
<ul>
<li>Trickster is an Laravel package that makes Laravel Fun.</li>
<li>Trickster provides tricks that makes coding with Laravel easy.</li>
<li>With <strong>Trickster</strong> inside your <strong>Laravel framework</strong>, your app will become a <strong>Gambit</strong>. :-P</li>
</ul>
<h2 id="installation">Installation</h2>
<p>Installing Trickster is easy. Just type the command: <br>
<code>composer require secrethash/trickster</code></p>
<h2 id="requirements">Requirements</h2>
<ul>
<li><strong>Laravel 5.x</strong></li>
<li><strong>cURL</strong></li>
<li><strong>PHP 5.4.x</strong></li>
</ul>
<h2 id="usage">Usage</h2>
<p>To start using <strong><em>Trickster</em></strong>, you will be needed to set it up first. Follow the below steps to setup <strong>Trickster</strong>:</p>
<h3 id="1-service-provider">1. Service Provider</h3>
<p>You will be needing to add the Trickster Service Provider in your <code>app.php</code> which is inside the <code>config</code> directory.</p>
<ul>
<li>Open <code>config\app.php</code></li>
<li>Find <code>'providers'</code></li>
<li>At the last of this array in <code>Application Service Providers</code> add <code>Secrethash\Trickster\TricksterServiceProvider::class,</code></li>
</ul>
<h3 id="2-facade">2. Facade</h3>
<p>To use <strong>Trickster</strong> flexibly, you need to add the Facade also. Facade will let you use Trickster directly. All you will need to do is add <code>use Trickster;</code> at the head of the controller below namespace and use it by <code>Trickster::trickName();</code></p>
<p><strong>Lets Add the <code>Trickster</code> Facade:</strong></p>
<ul>
<li>Open <code>config\app.php</code></li>
<li>Find <code>'aliases'</code> array.</li>
<li>At the end of this array, add <code>'Trickster' => Secrethash\Trickster\Facade\Trickster::class,</code></li>
</ul>
<h3 id="3-configuration">3. Configuration</h3>
<p>First of all you will need to run the following command in your console: <br>
<code>php artisan vendor:publish --provider="Secrethash\Trickster\TricksterServiceProvider"</code></p>
<blockquote>
<p>This command will publish the <code>trickster.php</code> configuration file for Trickster to your application default <code>config</code> directory.</p>
</blockquote>
<p>From <code>config\trickster.php</code> you can edit the default configurations.</p>
<h3 id="4-ready-steady-go">4. Ready, Steady, GO!</h3>
<p><strong><em>You are almost done. Now what to do when you want to use a Trickster’s Trick?</em></strong></p>
<p>Here is a sample Controller to show you how to add Trickster and Use it:</p>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-preprocessor"><?php</span>
<span class="hljs-keyword">namespace</span> <span class="hljs-title">App</span>\<span class="hljs-title">Http</span>\<span class="hljs-title">Controllers</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Illuminate</span>\<span class="hljs-title">Http</span>\<span class="hljs-title">Request</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">Http</span>\<span class="hljs-title">Requests</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Auth</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Trickster</span>; <span class="hljs-comment">// Simply add the Facade</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TricksterDemoController</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Controller</span>
{</span>
<span class="hljs-comment">/**
* Display a listing of the resource.
*
*<span class="hljs-phpdoc"> @return</span> \Illuminate\Http\Response
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">index</span><span class="hljs-params">()</span>
{</span>
<span class="hljs-comment">//checking if the user is Authenticated</span>
<span class="hljs-keyword">if</span> (Auth::check()) {
<span class="hljs-variable">$user</span> = Auth::user();
<span class="hljs-comment">// Grabbing Gravatar</span>
<span class="hljs-variable">$gravatar</span> = Trickster::gravatar(<span class="hljs-variable">$user</span>->email, <span class="hljs-string">'200'</span>);
}
}
<span class="hljs-comment">/**
* Show the form for creating a new resource.
*
*<span class="hljs-phpdoc"> @return</span> \Illuminate\Http\Response
*/</span>
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">create</span><span class="hljs-params">()</span>
{</span>
<span class="hljs-comment">//</span>
}
}
</code></pre>
<p>If you want to use Trickster inside a view file, call the <code>Trickster</code> method directly. That is the advantage of Facade.</p>
<p>For example: <br>
<code>{!! Trickster::bbcode($user->bio) !!}</code> <br>
or <br>
<code>{{ Trickster::truncator($blog->desc, '150', '(...summary)') }}</code></p>
<h2 id="tricksters-tricks">Trickster’s Tricks</h2>
<h3 id="1-truncator">1. Truncator</h3>
<p>Truncate is a Text Truncator. It Truncates the text and enable you to add ellipses(…) or desired line at the end. For example:</p>
<blockquote>
<p><em>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those inter <strong>(read more…)</strong></em></p>
</blockquote>
<p>Just call the Trickster and provide it with details of the given parameters.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::truncator(<span class="hljs-string">'Supplied text is written here, can also be given in a variable; lets leave it simple.'</span>, <span class="hljs-number">30</span>, <span class="hljs-string">'(read more...)'</span>);
<span class="hljs-comment">// Output: Supplied text is written here, (read more...)</span></code></pre>
<h3 id="2-email-validator">2. Email Validator</h3>
<p>Email Validator gives you the power of validating the email address by just a simple line of code: </p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::emailValid(<span class="hljs-string">'someone@example.com'</span>);</code></pre>
<p>With Trickster by your side you will not have to write the validation code again and again. Just mention the Facade of Trickster an the validation function that’s it.</p>
<h3 id="3-slug-converter">3. Slug Converter</h3>
<p>Slug Converter makes your life easy for creating search engine friendly slug for your url.</p>
<blockquote>
<p>For example: <strong>Text</strong>: <em>Are search engines friendly to search engines?</em></p>
<blockquote>
<p><strong>SLUGish URL</strong>: <em>example.com/are-search-engines-friendly-to-search-engines</em></p>
</blockquote>
</blockquote>
<p><strong><em>COOL HUH?</em></strong></p>
<p>It is really very simple with Trickster. Just call Trickster and specify the slug function, provide in the text and Ta-DA!</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::slug(<span class="hljs-string">'Are search engines friendly to search engines?'</span>); <span class="hljs-comment">// Just One Line!</span>
<span class="hljs-comment">//-> OR</span>
<span class="hljs-variable">$slug</span> = <span class="hljs-string">'Are search engines friendly to search engines?'</span>;
<span class="hljs-variable">$slug</span> = Trickster::slug(<span class="hljs-variable">$slug</span>); <span class="hljs-comment">// That's it!</span></code></pre>
<h3 id="4-youtube-embed">4. YouTube Embed</h3>
<p>YouTube Embedding can never be more easier! Embed YouTube Videos without writing lines of code just tell the Trickster about it. Call Trickster by:</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::youtube(<span class="hljs-string">'VIDEO URL'</span>, <span class="hljs-string">'FRAME WIDTH'</span>, <span class="hljs-string">'FRAME HEIGHT'</span>, <span class="hljs-string">'FRAME THEME'</span>);
<span class="hljs-comment">//OR LEAVE EVERYTHING ELSE FOR DEFAULT VALUES, JUST PUT THE LINK</span>
Trickster::youtube(<span class="hljs-string">'VIDEO URL'</span>);</code></pre>
<p><strong><em>DEFAULT VALUES:</em></strong></p>
<table>
<thead>
<tr>
<th>Parameters</th>
<th>Description</th>
<th>Required</th>
<th>Value</th>
</tr>
</thead>
<tbody><tr>
<td>Video URL</td>
<td>URL to the YouTube video</td>
<td>YES</td>
<td>NO</td>
</tr>
<tr>
<td>Frame Width</td>
<td>Width of the video Frame</td>
<td>NO</td>
<td>400</td>
</tr>
<tr>
<td>Frame Height</td>
<td>Height of the Video frame</td>
<td>NO</td>
<td>250</td>
</tr>
<tr>
<td>Frame Theme</td>
<td><strong>dark</strong> or <strong>light</strong> theme</td>
<td>NO</td>
<td>dark</td>
</tr>
</tbody></table>
<h3 id="5-gravatar-grabber">5. Gravatar Grabber</h3>
<p>This amazing trick helps you to easily get the gravatar in the desired <strong>size</strong>, with desired <strong>rating</strong>. Not only that, but it also helps you to set the desired <strong>default image</strong> in case the grabbing fails. Not yet finished, two more amazing features; allows you to <strong>set the option of returning only the url of the gravatar or even the gravatar with the whole <code><img /></code> tag</strong> and in case you want Trickster to return the whole <em>img</em> tag then you also have the option of <strong>setting desired attributes in an array <em>(ex. below)</em></strong>.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::gravatar(<span class="hljs-string">'example@email.com'</span>, <span class="hljs-string">'200'</span>, <span class="hljs-string">'monsterid'</span>, <span class="hljs-string">'r'</span>, <span class="hljs-string">'true'</span>, <span class="hljs-keyword">array</span>(<span class="hljs-string">'class'</span>=><span class="hljs-string">'img-class'</span>, <span class="hljs-string">'key'</span>=><span class="hljs-string">'value'</span>));</code></pre>
<p><strong>The Parameters Explained:</strong></p>
<ul>
<li><strong>Email Address</strong>: Just simple email address. <em>NO DEFAULT</em>, <em>REQUIRED</em>.</li>
<li><strong>Size</strong>: Size of image in pixels. <em>DEFAULT: 100</em>, <em>NOT REQUIRED</em>.</li>
<li><strong>Default image</strong>: Default Image like <em>mm</em>(mystery man), <em>monsterid</em>, <em>identicon</em>, <em>wavatar</em>, 404. <em>DEFAULT: mm</em>, <em>NOT REQUIRED</em>.</li>
<li><strong>Rating</strong>: Image Max Rating (for ex. <em>g</em>, <em>pg</em>, <em>r</em>, <em>x</em>). <em>DEFAULT: g</em>, <em>NOT REQUIRED</em>.</li>
<li><strong><code><img /></code></strong>: Do you want full HTML image tag? This parameter should be supplied with boolean value (TRUE/FALSE). <em>DEFAULT: false</em>, <em>NOT REQUIRED</em>.</li>
<li><strong>Key-Value Attributes</strong>: An array is to be passed to defined any special attributes required by the html image tag, if requested. <em>NO DEFAULT</em>, <em>NOT REQUIRED</em></li>
</ul>
<h3 id="6-extension-splitter">6. Extension Splitter</h3>
<p>This simple trick splits the file extension of the file supplied as the parameter and returns it. Simply call the Trickster and provide the full file name, the trick will split the file ext. from the file name and return it.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::getExtension(<span class="hljs-string">'really-funny.image.jpg'</span>);</code></pre>
<p><strong><em>Finished? Not Yet!</em></strong></p>
<h3 id="7-simple-social-analytics">7. Simple Social Analytics</h3>
<p>This trick eases your life, seriously. Simple and easy it is to show your social counts with Trickster. Trickster’s Simple Social Analytics shows the number of Shares or Comments over a specific URL on Facebook when the trick is executed.</p>
<blockquote>
<p>Note: Twitter has been deprecated. As of 20th November 2015 there’s no Tweet count API. <a href="https://blog.twitter.com/2015/hard-decisions-for-a-sustainable-platform">Know More</a></p>
</blockquote>
<ul>
<li>Supported Social Networks: <br>
<ul><li>Facebook</li>
<li><del>Twitter</del> (deprecated)</li></ul></li>
<li>Returned Strings <br>
<ul><li>Facebook <br>
<ul><li>Share Count</li>
<li>Comment Count</li></ul></li>
<li><del>Twitter</del> <br>
<ul><li><del>Tweets</del></li></ul></li></ul></li>
</ul>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-variable">$fbAnalytics</span> = Trickster::social(<span class="hljs-string">'facebook'</span>, <span class="hljs-string">'http://github.com/secrethash'</span>);
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$fbAnalytics</span>[<span class="hljs-string">'share_count'</span>].<span class="hljs-string">' Shares of Github.com/secrethash'</span>;
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$fbAnalytics</span>[<span class="hljs-string">'comment_count'</span>].<span class="hljs-string">' Comments on Github.com/secrethash'</span>;</code></pre>
<blockquote>
<p>Output 1: 95457821 Shares of Github.com/secrethash <br>
Output 2: 59865231 Comments on Github.com/secrethash</p>
</blockquote>
<p>(Don’t be bothered about the numbers, they are just random :-P )</p>
<p>BTW Simple, right?</p>
<h3 id="8-bb-code-engine">8. BB Code Engine</h3>
<p>BB code engine trick is a little distinctive. It’s actually amazing. It makes easy to convert the BB Code to HTML format. Easy to initialize, it makes it unique.</p>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-comment">// If implemented directly in the Blade View File.</span>
{!! Trickster::bbcode(<span class="hljs-variable">$user</span>->bio) !!}</code></pre>
<p><strong><em>The Supported BB Codes Currently are: </em></strong></p>
<table>
<thead>
<tr>
<th>BB Code</th>
<th>Description</th>
<th>Converted HTML</th>
</tr>
</thead>
<tbody><tr>
<td>[b]…[/b]</td>
<td>Bold Text</td>
<td><code><b>...</b></code></td>
</tr>
<tr>
<td>[i]…[/i]</td>
<td>Italics Text</td>
<td><code><i>...</i></code></td>
</tr>
<tr>
<td>[u]…[/u]</td>
<td>Underlined</td>
<td><code><u>...</u></code></td>
</tr>
<tr>
<td>[img=url]alt[/img]</td>
<td>Image Implementation. Where: url is the image url & alt is alternate text.</td>
<td><code><img src="#url" alt="Alternate Text" /></code></td>
</tr>
<tr>
<td>[youtube]id[/youtube]</td>
<td>Youtube Embed. Where id is the Video ID of youtube video.</td>
<td>YouTube video frame of width 400px & height 250px</td>
</tr>
<tr>
<td>[vimeo]id[/vimeo]</td>
<td>Vimeo Embed. Where id is the Video ID of Vimeo video.</td>
<td>Vimeo video frame of width 400px & height 250px</td>
</tr>
<tr>
<td>[p]…[/p]</td>
<td>Paragraph.</td>
<td><code><p>...</p></code></td>
</tr>
<tr>
<td>[br/]</td>
<td>Line Break</td>
<td><code><br/></code></td>
</tr>
<tr>
<td>[url=URL]ALT[/url]</td>
<td>Adding a URL. Where: URL is the Target Link and ALT is the URL text to be shown.</td>
<td><code><a href="#url">Google</a></code></td>
</tr>
</tbody></table>
<h3 id="9-tags-sweeper">9. Tags Sweeper</h3>
<p>Tag sweeper is a unwanted tag remover trick. It easily removes the unwanted script tags from the provided string. In accordance to the BB Code Engine, Tag Sweeper Cleans the HTML <code><script></script></code> code and leaves the BB Code making the supplied text <strong>Clean and Safe</strong>.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::clean(<span class="hljs-variable">$string</span>);</code></pre>
<h3 id="10-time-ago">10. Time Ago</h3>
<p><strong>Time ago</strong> is a wonderful way of displaying the post time. You can use the Trickster’s Facade <code>Trickster</code> to convert easily the provided Time & Date to Time Ago. The default format for this is <code>Y-m-d H:i:s</code>. In simple words <code>1996-07-30 21:52:30</code>, <code>Year-Month-Day Hour:Min:Sec</code></p>
<blockquote>
<p>For example: <em>This repo was created 2 months ago</em></p>
</blockquote>
<p><strong>Trick:</strong></p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::timeAgo(<span class="hljs-string">'1996-07-30 21:52:30'</span>);</code></pre>
<h3 id="11-cipher">11. Cipher</h3>
<p>Cipher enables you to encrypt any provided string of plain text to convert into Encrypted text form. Any PHP supported algorithm can be provided to <strong>Cipher</strong> to encrypt it. You can also encrypt a string and add a <strong>Salt</strong> to make it more secure. One will need the <strong>Salt</strong> to decrypt it.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::encryptString(<span class="hljs-string">'SHA1'</span>, <span class="hljs-string">'Text to Encrypt'</span>, <span class="hljs-string">'Desired Salt'</span>);</code></pre>
<h3 id="12-vimeo-video-embed">12. Vimeo Video Embed</h3>
<p>Vimeo Video Embed, same as YouTube Video Embed. It needs the video link of Vimeo Video as an input. Same as Youtube Embed you can set custom width and height in it also. </p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::vimeo(<span class="hljs-string">'https://vimeo.com/30626474'</span>, <span class="hljs-string">'400'</span>, <span class="hljs-string">'250'</span>);
<span class="hljs-comment">//-> OR, Simple <-//</span>
Trickster::vimeo(<span class="hljs-string">'https://vimeo.com/30626474'</span>);</code></pre>
<h3 id="13-video-info-grabber">13. Video Info Grabber</h3>
<p>A great way of getting the video information from <strong>YouTube and Vimeo</strong>. <em>Video Info Grabber</em> makes it easy for you to grab the video info from link of YouTube & Vimeo video portals and return an array containing the video info. Returning as an array gives you the flexibility to use the info as you want.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::getVideoInfo(<span class="hljs-string">'https://vimeo.com/30626474'</span>);</code></pre>
<pre class="prettyprint"><code class="language-html hljs ">// Output
Array
(
[title] => The Official Space Ibiza Closing Party 2011 Video
[description] =>
[thumbnail] => http://i1.ytimg.com/vi/AL-QX0wj44A/default.jpg
[duration] => 962
[upload_date] => 2011-11-05 02:11:05
)</code></pre>
<h3 id="14-wikipedia-grabber">14. Wikipedia Grabber</h3>
<p>This simple trick helps you to get the <strong>Wikipedia version definition</strong> of a particular keyword. Just pass the key word as the input to this function of <code>Trickster</code> and get the definition right away as return string. Remember, like the above function this one also returns an array as it returns not only definition but also the input value and the link to Wikipedia, where that definition is. The example is well explained below:</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::wiki(<span class="hljs-string">'github'</span>);</code></pre>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-comment">// Returns</span>
<span class="hljs-keyword">Array</span>
(
[<span class="hljs-number">0</span>] => GitHub
[<span class="hljs-number">1</span>] => GitHub is a web-based Git repository hosting service. It offers all of the distributed revision control <span class="hljs-keyword">and</span> source code management (SCM) functionality of Git <span class="hljs-keyword">as</span> well <span class="hljs-keyword">as</span> adding its own features.
[<span class="hljs-number">2</span>] => http:<span class="hljs-comment">//en.wikipedia.org/wiki/GitHub</span>
)
</code></pre>
<p>So if you only want to display the definition of <strong>GitHub</strong> as shown in the above example:</p>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-variable">$trick</span> = Trickster::wiki(<span class="hljs-string">'github'</span>);
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$trick</span>[<span class="hljs-number">1</span>];</code></pre>
<h3 id="15-url-shortener">15. URL Shortener</h3>
<p>URL shortener make your url short using the Google’s goo.gl API and TinyURL API. Make your life simple with just one liner URL Shortener that can shorten the URL using 2 distinctive APIs.</p>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-comment">// Google's URL Shortener</span>
Trickster::shortenUrl(<span class="hljs-string">'http://github.io'</span>, <span class="hljs-string">'google'</span>);
<span class="hljs-comment">// TinyURL URL Shortener</span>
Trickster::shortenUrl(<span class="hljs-string">'http://github.com'</span>, <span class="hljs-string">'tinyurl'</span>);</code></pre>
<h3 id="16-suggest">16. Suggest</h3>
<p>Suggest uses the Google Suggest API to get the keyword suggestions. Just provide the input of the keyword that you want the suggestions for as the first parameter and the results will be generated and returned as an array.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::suggest(<span class="hljs-string">'break'</span>);</code></pre>
<pre class="prettyprint"><code class="language-php hljs "><span class="hljs-comment">// Output</span>
<span class="hljs-keyword">Array</span>
(
[<span class="hljs-number">0</span>] => breaking
[<span class="hljs-number">1</span>] => breaking bad
[<span class="hljs-number">2</span>] => <span class="hljs-keyword">break</span> the glass
[<span class="hljs-number">3</span>] => <span class="hljs-keyword">break</span> plan
[<span class="hljs-number">4</span>] => breaking bad imdb
[<span class="hljs-number">5</span>] => kitkat <span class="hljs-keyword">break</span>
[<span class="hljs-number">6</span>] => <span class="hljs-keyword">break</span> the bones
[<span class="hljs-number">7</span>] => breakthrough
[<span class="hljs-number">8</span>] => breaking benjamin
[<span class="hljs-number">9</span>] => breakup
)</code></pre>
<h3 id="17-ip-grabber">17. IP Grabber</h3>
<p>Grabs the user’s IP address. Simple but useful.</p>
<pre class="prettyprint"><code class="language-php hljs ">Trickster::ip();
<span class="hljs-comment">// Output: 192.168.145.35</span></code></pre>
<h3 id="18-currency-converter">18. Currency Converter</h3>
<p>With the help of <strong><em>CURL</em></strong> and <strong><em>Google</em></strong> the currency is converted using the live exchange rate. Trickster’s <code>Trickster::currencyConvert()</code> can convert currency within seconds using the Currency Codes.</p>
<p>The Currency Converter excepts three Parameters with last an optional one.</p>
<p>Parameters & Inputs:</p>
<table>
<thead>
<tr>
<th>Parameters</th>
<th>Description</th>
<th>Value</th>
<th>Default</th>
<th>Accepts</th>
</tr>
</thead>
<tbody><tr>
<td>Amount</td>
<td>The amount to convert</td>
<td>Integer</td>
<td><strong>——</strong></td>
<td>Currency Amount</td>
</tr>
<tr>
<td>From</td>
<td>Convert Currency From</td>
<td>String</td>
<td><strong>——</strong></td>
<td>Currency Code</td>
</tr>
<tr>
<td>To</td>
<td>Convert Currency To</td>
<td>String</td>
<td><strong>INR</strong></td>
<td>Currency Code</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>INR</strong> is the Currency Code for <strong>Indian National Rupee</strong></p>
</blockquote>
<pre class="prettyprint"><code class="language-php hljs "> <span class="hljs-comment">/**
* Sample Code
*<span class="hljs-phpdoc"> @param</span> $amount init Amount to convert
*<span class="hljs-phpdoc"> @param</span> $from string Currency Code
*<span class="hljs-phpdoc"> @param</span> $to string Currency Code
*<span class="hljs-phpdoc"> @return</span> string - converted amount
**/</span>
<span class="hljs-variable">$amount</span> = <span class="hljs-number">100</span>;
<span class="hljs-variable">$from</span> = <span class="hljs-string">"USD"</span>;
<span class="hljs-variable">$to</span> = <span class="hljs-string">"INR"</span>;
<span class="hljs-variable">$convert</span> = Trickster::currencyConvert(<span class="hljs-variable">$amount</span>, <span class="hljs-variable">$from</span>, <span class="hljs-variable">$to</span>);
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$convert</span>;</code></pre>
<pre class="prettyprint"><code class=" hljs http"><span class="hljs-attribute">output</span>: <span class="hljs-string">60,000 //In INR (Just an Example).</span></code></pre></div></body>
</html>