forked from YOURLS/YOURLS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.html
728 lines (658 loc) · 33.1 KB
/
readme.html
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE-9"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>YOURLS: Your Own URL Shortener</title>
<link href='https://fonts.googleapis.com/css?family=Fira+Sans:400,700' rel='stylesheet' type='text/css'>
<style type="text/css" media="screen">
/* Default Style */
body {
font-family: Verdana, Arial, sans-serif;
font-size: 12px;
color: #595441;
background:#E3F3FF;
margin-top:0px;
margin-bottom:30px;
}
p {
padding-left: 10px;
}
code {
background:#eaeaef;
padding:0 2px;
}
tt {
background:#ffc;
padding:0 2px;
}
pre tt {
display:block;
}
blockquote {
margin: 10px 20px 0px 20px;
padding: 10px;
border: 1px solid #8d8d8d;
background-color: #f5f5f5;
}
li {
margin-top: 20px;
}
ul li ul li {
margin-top: 10px;
}
a, a:active, a:link, a:visited {
color: #7ba7e4;
text-decoration: none;
}
a:hover {
color: #5577a5;
text-decoration: underline;
}
div.sshot {
}
div.sshot p {
zcolor:#5577a5;
zfont-size:90%;
}
div.sshot img {
margin-bottom:1em;
border:1px solid #2A85B3;
padding:10px;
border-radius:10px;
}
#fade {
position:absolute; background: #E3F3FF; width:100%; height:230px; top:0px; left:0px; z-index:-1;
background: -webkit-gradient(linear, left top, left bottom, from(rgba(227, 243, 255, 1)), to(rgba(227, 243, 255, 0)));
background: -moz-linear-gradient(top, rgba(227, 243, 255, 1), rgba(227, 243, 255, 0.1)); /* for firefox 3.6+ */
}
/* Place Holder Style */
#Container {
width: 850px;
margin-left: auto;
margin-right: auto;
z-index:1337;
}
#Content {
background: none repeat scroll 0 0 white;
border: 3px solid #2A85B3;
-moz-border-radius:20px;
-webkit-border-radius:20px;
border-radius: 20px;
margin-top:-13px;
min-height: 150px;
padding: 5px 20px 10px;
text-align: left;
z-index:2;
}
/* Title Style */
h1{margin:0px}
#Container h1 a {
display:block;
font-family: 'Fira Sans', Verdana, Arial;
font-size: 32px;
font-weight: 700;
color: #2A85B3;
margin-top:0px;
margin-bottom: 0px;
background:transparent url(images/yourls-logo.svg) left 5px no-repeat;
background-size: 220px;
padding-top:15px;
height:80px;
padding-left:250px;
text-align:left;
}
h1 a:hover{text-decoration:none}
h1 a:hover span {
color: #88C0EB;
text-decoration:underline;
}
h2 {
font-family: 'Fira Sans', Verdana, Arial;
font-size: 22px;
font-weight: 700;
color: #5b87b4;
margin-top:50px;
}
h2.first{margin-top:10px}
h2:before {
content: '\00BB ';
color:#BFE0FE;
}
h3 {
font-family: 'Fira Sans', Verdana, Arial;
font-size: 18px;
font-weight: bold;
color: #73a4d6;
margin-top:2em;
}
h3:before {
content: '\203A ';
color:#BFE0FE;
}
a.anch span {
display:none;
}
.highlight {
animation-name: pulsedown;
animation-duration: 4s;
animation-iteration-count: 1;
}
@keyframes pulsedown {
0% {background-color: #FFFF00;}
100 {background-color: transparent;}
}
/* Tabs */
ul#Tabs {
font-family: Verdana, Arial;
font-size: 13px;
font-weight: 400;
list-style-type: none;
padding-bottom: 28px;
border-bottom: 1px solid #2A85B3;
margin:0 30px 12px 30px;
z-index: 1;
}
#Tabs li.Tab {
float: right;
height: 23px;
background-color: #deedfb;
margin: 3px 0px 0px 5px;
border: 2px solid #2A85B3;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
#Tabs li.Tab a {
float: left;
display: block;
color: #666666;
text-decoration: none;
padding: 3px 5px;
}
#Tabs li.Tab a:hover {
background-color: #bfe0fe;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
/* Selected Tab */
#Tabs li.SelectedTab {
float: right;
height: 24px;
background-color: #fff;
margin: 0px 0px 0px 5px;
border-top: 2px solid #2A85B3;
border-right: 2px solid #2A85B3;
border-left: 2px solid #2A85B3;
border-bottom: 6px solid #fff;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
#Tabs li.SelectedTab a {
float: left;
display: block;
color: #666666;
text-decoration: none;
padding: 5px;
cursor: default;
}
</style>
<!--[if IE]> <style>#fade{display:none}</style> <![endif]-->
</head>
<body>
<div id="fb-root"></div>
<div id="Container">
<!-- Title -->
<header role="banner">
<h1><a href="https://yourls.org/">YOURLS: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener</a></h1>
</header>
<main role="main">
<!-- Tabs -->
<ul id="Tabs">
<li id="MoreTab" class="Tab"><a href="#More" onclick="toggle(this);">More</a></li>
<li id="FAQTab" class="Tab"><a href="#FAQ" onclick="toggle(this);">FAQ</a></li>
<li id="APITab" class="Tab"><a href="#API" onclick="toggle(this);">API</a></li>
<li id="PluginsTab" class="Tab"><a href="#Plugins" onclick="toggle(this);">YOURLS plugins</a></li>
<li id="ConfigTab" class="Tab"><a href="#Config" onclick="toggle(this);">Config</a></li>
<li id="InstallTab" class="Tab"><a href="#Install" onclick="toggle(this);">Install/Upgrade</a></li>
<li id="AboutTab" class="SelectedTab"><a href="#About" onclick="toggle(this);">About</a></li>
</ul>
<!-- Content -->
<div id="Content">
<!-- Index -->
<div id="AboutDiv">
<a class="anch" href="#About;about"><span>➤</span><h2 id="about" class="first">About YOURLS</h2></a>
<a class="anch" href="#About;what"><span>➤</span><h3 id="what">What is YOURLS</h3></a>
<p><strong>YOURLS</strong> stands for <strong>Your Own URL Shortener</strong>. It is a small set of PHP scripts that will allow you to run your own URL shortening service (<em>a la</em> TinyURL or Bitly).</p>
<p>Running your own URL shortener is fun, geeky and useful: you own your data and don't depend on third-party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.</p>
<a class="anch" href="#About;features"><span>➤</span><h3 id="features">YOURLS Features</h3></a>
<ul>
<li><tt>Free</tt> and <tt>open-source</tt> software,</li>
<li><tt>Private</tt> (your links only) or <tt>Public</tt> (everybody can create short links, fine for an intranet),</li>
<li>Terrific <tt>Plugin</tt> architecture and dozens of <tt>plugins</tt> to easily implement new features,</li>
<li>Handy <tt>bookmarklets</tt> to easily shorten and share links,</li>
<li>Awesome <tt>stats</tt>: historical click reports, referrers tracking, visitors geo-location,</li>
<li>Developer <tt>API</tt> to integrate YOURLS into other applications,</li>
<li>Friendly <tt>installer</tt>,</li>
<li><tt>Sample files</tt> to create your own public interface and more !</li>
</ul>
<a class="anch" href="#About;screenshots"><span>➤</span><h3 id="screenshots">Screenshots</h3></a>
<div class="sshot">
<p>Main admin dashboard</p>
<img src="images/admin-dashboard.gif" />
<p>Stats for each short URL</p>
<img src="images/stats-anim.gif" />
</div>
<a class="anch" href="#About;download"><span>➤</span><h2 id="download">Download</h2></a>
<p><a href="https://yourls.org/download">Download YOURLS</a> from GitHub and see see the <a href="#Install" onclick="toggle(this);">Install</a> guide</p>
<a class="anch" href="#About;credits"><span>➤</span><h2 id="credits">Credits</h2></a>
<p>YOURLS is made by <a href="https://github.com/YOURLS/YOURLS/graphs/contributors">awesome people</a>.</p>
<p>Keep up to date: read the official <a href="https://yourls.org/blog">YOURLS Blog</a>.</p>
</div>
<!-- Installation Instructions -->
<div id="InstallDiv" style="display: none;">
<a class="anch" href="#Install;fresh"><span>➤</span><h2 id="fresh" class='first'>Fresh Install</h2></a>
<ol>
<li>Unzip the YOURLS archive</li>
<li>Copy <code>user/config-sample.php</code> to <code>user/config.php</code></li>
<li>Open <code>user/config.php</code> with a raw text editor (like Notepad) and fill in the required settings</li>
<li>Upload the unzipped files to your domain <code>public_html</code> or <code>www</code> folder</li>
<li>Create a new database (see <a href="#Config" onclick="toggle(this);">Configuration</a> – you can also use an existing one)</li>
<li>Point your browser to <code>http://your-own-domain-here.com/admin/</code></li>
</ol>
<a class="anch" href="#Install;auto"><span>➤</span><h3 id="auto" class='first'>Install Guides</h3></a>
<p>The documentation on <a href="https://docs.yourls.org/">docs.yourls.org</a> is full of important information. Regarding installation, you'll find help for Apache and Nginx.</p>
<p>You will also find numerous unofficial installation guides on <a href="https://yourls.org/awesome">Awesome YOURLS</a>, a curated list of resources.</p>
<a class="anch" href="#Install;upgrade"><span>➤</span><h2 id="upgrade">Upgrade</h2></a>
<ol>
<li><strong>Backup the database!</strong></li>
<li>Unzip the YOURLS archive</li>
<li>Upload files to your server, overwriting your existing install (this won't affect user files such as config or plugins)</li>
<li>Point your browser to <code>http://your-own-domain-here.com/admin/</code></li>
</ol>
</div>
<!-- Configuration Instructions -->
<div id="ConfigDiv" style="display: none;">
<a class="anch" href="#Config;configuration"><span>➤</span><h2 id="configuration" class='first'>Configuration (in <code>user/config.php</code>)</h2></a>
<a class="anch" href="#Config;mysql"><span>➤</span><h3 id="mysql">MySQL settings</h3></a>
<ul>
<li><code>YOURLS_DB_USER</code><br/>
your MySQL username<br/>
<em>Example:</em> <tt>define( 'YOURLS_DB_USER', 'joe' );</tt></li>
<li><code>YOURLS_DB_PASS</code><br/>
your MySQL password<br/>
<em>Example:</em> <tt>define( 'YOURLS_DB_PASS', 'MySeCreTPaSsW0rd' );</tt></li>
<li><code>YOURLS_DB_NAME</code>:
The database name<br/>
<em>Example:</em> <tt>define( 'YOURLS_DB_NAME', 'yourls' );</tt></li>
<li><code>YOURLS_DB_HOST</code><br/>
The database host<br/>
<em>Example:</em> <tt>define( 'YOURLS_DB_HOST', 'localhost' );</tt></li>
<li><code>YOURLS_DB_PREFIX</code><br/>
The name prefix for all the tables YOURLS will need<br/>
<em>Example:</em> <tt>define( 'YOURLS_DB_PREFIX', 'yourls_' );</tt></li>
</ul>
<a class="anch" href="#Config;site"><span>➤</span><h3 id="site">Site options</h3></a>
<ul>
<li><code>YOURLS_SITE</code><br/>
Your (hopefully short) domain URL, no trailing slash, lowercase. If you pick the non-www version of your domain, don't use the www version in your browser (and vice-versa)<br/>
<em>Example:</em> <tt>define( 'YOURLS_SITE', 'https://your-own-domain-here.com' );</tt></li>
<li><code>YOURLS_PRIVATE</code><br/>
Private means the admin area will be protected with login/pass as defined below. See <a href="https://yourls.org/privatepublic">Private or Public</a> for more.<br/>
<em>Example:</em> <tt>define( 'YOURLS_PRIVATE', true );</tt></li>
<li><code>YOURLS_UNIQUE_URLS</code><br/>
Allow multiple short URLs for a same long URL<br/>
Set to <tt>true</tt> to allow only one pair of shortURL/longURL (default YOURLS behavior), or to <tt>false</tt> to allow creation of multiple short URLs pointing to the same long URL (as bit.ly does)<br/>
<em>Example:</em> <tt>define( 'YOURLS_UNIQUE_URLS', true );</tt></li>
<li><code>YOURLS_COOKIEKEY</code><br/>
A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: generate a unique one at <a href="https://yourls.org/cookie">https://yourls.org/cookie</a><br/>
<em>Example:</em> <tt>define( 'YOURLS_COOKIEKEY', 'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm' );</tt></li>
<li><code>yourls_user_passwords</code><br/>
A list of username(s) and password(s) allowed to access the site if private<br/>
Passwords can either be in plain text, or encrypted: see <a href="https://yourls.org/userpassword">https://yourls.org/userpassword</a> for more information.<br/>
<em>Example:</em> <tt>'joe' => 'mypassword'</tt></li>
</ul>
<a class="anch" href="#Config;urlsettings"><span>➤</span><h3 id="urlsettings">URL Shortening settings</h3></a>
<ul>
<li><code>YOURLS_URL_CONVERT</code><br/>
URL shortening method: base <tt>36</tt> or <tt>62</tt>. See <a onclick="toggle(this);" href="#FAQ">FAQ</a> for more explanations</li>
<li><code>yourls_reserved_URL</code><br/>
A list of reserved keywords that won't be used as short URLs. Define here negative, unwanted or potentially misleading keywords<br/>
<em>Example:</em> <tt>'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick'</tt></li>
</ul>
<a class="anch" href="#Config;optional"><span>➤</span><h3 id="optional">Optional settings</h3></a>
<ul>
<li><code>YOURLS_PRIVATE_INFOS</code><br/>
If <code>YOURLS_PRIVATE</code> is set to <tt>true</tt>, you can still make stat pages public. To do so, define with:<br/>
<tt>define('YOURLS_PRIVATE_INFOS', false);</tt>
</li>
<li><code>YOURLS_PRIVATE_API</code><br/>
If <code>YOURLS_PRIVATE</code> is set to <tt>true</tt>, you can still make your API public. To do so, define with:<br/>
<tt>define('YOURLS_PRIVATE_API', false);</tt>
<li><code>YOURLS_NOSTATS</code><br/>
If <code>YOURLS_NOSTATS</code> is set to <tt>true</tt>, redirects won't be logged and there will be not stats available.<br/>
</li>
</ul>
<a class="anch" href="#Config;advanced"><span>➤</span><h3 id="advanced">Advanced settings</h3></a>
<ul>
<li>You can install YOURLS behind a firewall or a proxy: see <a href="https://yourls.org/proxy">Proxy Support</a></li>
<li>File <code>includes/Config/Config.php</code> contains a few more undocumented but self explanatory and commented settings. Add them to your own <code>config.php</code> if you know what you're doing.</li>
<li>There are numerous tips and guides on the <a href="https://docs.yourls.org/">Documentation</a>, be sure to read them.</li>
</ul>
</div>
<!-- YOURLS plugins -->
<div id="PluginsDiv" style="display:none">
<a class="anch" href="#Plugins;plugins-for-yourls"><span>➤</span><h2 id="plugins-for-yourls" class="first">Plugins for YOURLS</h2></a>
<a class="anch" href="#Plugins;plugins"><span>➤</span><h3 id="plugins">Plugins?</h3></a>
<p>Plugins are additional PHP scripts that extend the functionalities or features of YOURLS. The core of YOURLS is designed to be as light as possible and avoid bloat (implementing functions not everybody needs) and to allow for easy customization.</p>
<p>Using the plugin architecture, you can add new features to YOURLS without having to modify core files. This way, your changes won't be lost when you upgrade your YOURLS installation and you can easily activate and deactivate a plugin from the admin interface.</p>
<p>There's a growing number of plugins available: check the <a href="https://yourls.org/awesome">Plugin list</a>.</p>
<a class="anch" href="#Plugins;documentation"><span>➤</span><h3 id="documentation">Documentation</h3></a>
<p>Several sample plugins are included in the archive. Read the source and learn the concept. It's easy and fun!</p>
<p>Check the <a href="https://yourls.org/pluginapi">plugin API documentation</a> to learn more</p>
</div>
<!-- API -->
<div id="APIDiv" style="display:none">
<a class="anch" href="#API;yourls-api"><span>➤</span><h2 id="yourls-api" class="first">YOURLS' API</h2></a>
<a class="anch" href="#API;apifeatures"><span>➤</span><h3 id="apifeatures">Features</h3></a>
<ul>
<li>Generate or get existing short URLs, with sequential or custom keyword</li>
<li>Get some statistics about your links: top clicked links, least clicked links, newest links</li>
<li>Output format: JSON, XML, or simple raw text</li>
<li>Authentify either with login/password or using a secure passwordless mechanism</li>
</ul>
<a class="anch" href="#API;apiusage"><span>➤</span><h3 id="apiusage">Usage</h3></a>
<p>You need to send parameters to <code>http://your-own-domain-here.com/yourls-api.php</code> either via <code>GET</code> or <code>POST</code> (remember to <strong>URL-encode parameters</strong> if via GET). These parameters are:</p>
<ul>
<li>A valid <code>username</code> / <code>password</code> pair, or your <code>signature</code> (see <a href="https://yourls.org/passwordlessapi">Passwordless API requests</a>)</li>
<li>The requested <code>action</code>: <tt>"shorturl"</tt> (get short URL for a link), <tt>"expand"</tt> (get long URL of a shorturl), <tt>"url-stats"</tt> (get stats about one short URL), <tt>"stats"</tt> (get stats about your links) or <tt>"db-stats"</tt> (get global link and click count)</li>
<li>With <tt>action = "shorturl"</tt> :
<ul>
<li>the <code>url</code> to shorten</li>
<li>optional <code>keyword</code> and <code>title</code> for custom short URLs</li>
<li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li>
</ul>
</li>
<li>With <tt>action = "expand"</tt> :
<ul>
<li>the <code>shorturl</code> to expand (can be either 'abc' or 'http://site/abc')</li>
<li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li>
</ul>
</li>
<li>With <tt>action = "url-stats"</tt> :
<ul>
<li>the <code>shorturl</code> for which to get stats (can be either 'abc' or 'http://site/abc')</li>
<li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt> or <tt>"xml"</tt></li>
</ul>
</li>
<li>With <tt>action = "stats"</tt> :
<ul>
<li>the <code>filter</code>: either <tt>"top"</tt>, <tt>"bottom"</tt> , <tt>"rand"</tt> or <tt>"last"</tt></li>
<li>the <code>limit</code> (maximum number of links to return)</li>
<li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt> or <tt>"xml"</tt></li>
</ul>
</li>
<li>With <tt>action = "db-stats"</tt> :
<ul>
<li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt> or <tt>"xml"</tt></li>
</ul>
</li>
<li>With <tt>action = "version"</tt> :
<ul>
<li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li>
</ul>
</li>
</ul>
<a class="anch" href="#API;apiexample"><span>➤</span><h3 id="apiexample">Sample requests</h3></a>
<p>Example of a <tt>GET</tt> request with Javascript (using jQuery) to shorten a URL</p>
<pre><tt>var api_url = 'http://sho.rt/yourls-api.php';
var response = $.get( api_url, {
username: "your_username",
password: "your_password",
action: "shorturl",
format: "json",
url: "http://ozh.org/"
},
// callback function that will deal with the server response
function( data) {
// now do something with the data, for instance show new short URL:
alert(data.shorturl);
}
);</tt></pre>
<p>Example of a <tt>POST</tt> request with PHP to expand a short URL</p>
<pre><tt><?php
$username = 'your_username';
$password = 'your_password';
$api_url = 'http://sho.rt/yourls-api.php';
// Init the CURL session
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result
curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request
curl_setopt($ch, CURLOPT_POSTFIELDS, array( // Data to POST
'shorturl' => 'ozh',
'format' => 'json',
'action' => 'expand',
'username' => $username,
'password' => $password
));
// Fetch and return content
$data = curl_exec($ch);
curl_close($ch);
// Do something with the result. Here, we echo the long URL
$data = json_decode( $data );
echo $data->longurl;</tt></pre>
<a class="anch" href="#API;apireturn"><span>➤</span><h3 id="apireturn">Sample returns</h3></a>
<p>Sample return in JSON format for the <code>shorturl</code> action</p>
<pre><tt>{
"url": {
"keyword": "ozh",
"url": "http:\/\/ozh.org",
"title": "Ozh RICHARD \u00ab ozh.org",
"date": "2014-10-24 16:01:39",
"ip": "127.0.0.1"
},
"status": "success",
"message": "http:\/\/ozh.org added to database",
"title": "Ozh RICHARD \u00ab ozh.org",
"shorturl": "http:\/\/sho.rt\/1f",
"statusCode": "200"
}</tt></pre>
<p>Sample return in XML format for the <code>expand</code> action</p>
<pre><tt><result>
<keyword>ozh</keyword>
<shorturl>http://sho.rt/ozh</shorturl>
<longurl>http://ozh.org/</longurl>
<message>success</message>
<statusCode>200</statusCode>
</result></tt></pre>
<a class="anch" href="#API;apisample"><span>➤</span><h3 id="apisample">Sample file</h3></a>
<p>There's a sample PHP file included that serves as an example on how to play with the API</p>
<a class="anch" href="#API;expand_api"><span>➤</span><h3 id="expand_api">Expand the API</h3></a>
<p>You can easily implement custom API actions with a plugin. See the <a href="https://yourls.org/awesome">plugin list</a> for examples.</p>
</div>
<!-- FAQ Instructions -->
<div id="FAQDiv" style="display: none;">
<a class="anch" href="#FAQ;theFAQ"><span>➤</span><h2 id="theFAQ" class="first">FAQ</h2></a>
<a class="anch" href="#FAQ;requirement"><span>➤</span><h3 id="requirement">Server requirements and recommendations</h3></a>
<ol>
<li>We recommend <strong>PHP 7.4</strong> or above</li>
<li>You will need at least <strong>MYSQL 5</strong></li>
<li>A web server with <strong>mod_rewrite</strong> enabled<br/>
<em>Note</em>: YOURLS can also run on <a href="https://docs.yourls.org/guide/server-configuration.html#nginx">Nginx</a>,
<a href="https://github.com/lylebrown/YOURLS-Cherokee">Cherokee</a> and <a href="https://github.com/YOURLS/awesome-yourls#installation-guides">more</a> !</li>
<li><strong>HTTPS</strong> support</li>
<li>PHP <a href="http://www.php.net/curl">CURL extension</a> installed if you plan on playing with the API</li>
</ol>
<a class="anch" href="#FAQ;limitations"><span>➤</span><h3 id="limitations">Limitations</h3></a>
<ul>
<li>Maximum length of custom keyword is <strong>100 characters</strong></li>
<li>That makes <strong>several septillions of quinquagintillion</strong> of possible short URLs (<a href="http://en.wikipedia.org/wiki/Names_of_large_numbers">seriously</a>. That's a 180-digit number). </li>
</ul>
<a class="anch" href="#FAQ;base3662"><span>➤</span><h3 id="base3662">Difference Between Base 36 And Base 62 Encoding</h3></a>
<ul>
<li>Base 36 encoding uses <code>0123456789abcdefghijklmnopqrstuvwxyz</code> for short URLs</li>
<li>Base 62 encoding uses <code>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</code></li>
<li>Stick to one setting, don't change after you've created links as it will change all your short URLs!</li>
<li>Base 36 is the default and should be picked if you're not sure.</li>
</ul>
<a class="anch" href="#FAQ;shortdomain"><span>➤</span><h3 id="shortdomain">Getting a short domain name for your YOURLS install</h3></a>
<ul>
<li>Unless you plan on making it public and as popular as bit.ly, any shared hosting will be fine. Ozh runs all his YOURLS instance on <a href="https://yourls.org/dreamhost">Dreamhost</a> and it works just great.</li>
<li><a href="http://domai.nr/">Domainr</a> is a fun search tool that might inspire and help you</li>
<li>Aim for exotic top-level domains (.in, .im, .li ...), they're often cheap and a lot are still available. <a href="http://yourls.org/gandi">Gandi</a> is a pretty comprehensive registrar, for instance.</li>
</ul>
<a class="anch" href="#FAQ;htaccess"><span>➤</span><h3 id="htaccess">YOURLS needs its own .htaccess</h3></a>
<ul>
<li>You cannot install YOURLS and, say, WordPress, in the same directory. Both need to handle URLs differently and need their own <tt>.htaccess</tt> file.</li>
<li>If you want to install YOURLS on the same domain than your blog, give it its own (short) subdirectory, such as yourblog.com/s/ (for "short") or yourblog.com/x/ (for "exit")</li>
</ul>
<a class="anch" href="#FAQ;does404"><span>➤</span><h3 id="does404">If YOURLS generates 404 for your short URLs</h3></a>
<ul>
<li>Make sure <strong>mod_rewrite</strong> is enabled with your Apache server</li>
<li>Make sure your .htaccess file looks like <a href="https://yourls.org/htaccess">this one</a></li>
<li>Check that your server Apache configuration allows use of .htaccess (<tt>AllowOverride All</tt> directive, ask your server admin)</li>
<li>Eventually, refer to <a href="https://yourls.org/support">Troubleshooting first steps</a>.</li>
</ul>
<a class="anch" href="#FAQ;sequential"><span>➤</span><h3 id="sequential">Random versus sequential short URLs</h3></a>
<ul>
<li>Out of the box, YOURLS generates sequential short URLS (ie <code>ab31</code>, then <code>ab32</code> and so on)</li>
<li>If you prefer random short URLs (ie <code>j3kz1</code> then <code>13hz7</code> like Bitly does), just activate the plugin that comes with YOURLS.</li>
</ul>
<a class="anch" href="#FAQ;stats"><span>➤</span><h3 id="stats">"Stats don't update as I think they should", "difference with Google Analytics", etc...</h3></a>
<ul>
<li>Out of the box, YOURLS updates traffic stats every time a short URL is requested. Period.</li>
<li>This said, some clients (like indexing bots, your internet browser) may skip requesting a short URL if they have the final destination known in cache.</li>
<li>Conversely, other stat tools may use different techniques to track hits (using javascript or not, using IP address, filtering multiple requests by same client, etc...)</li>
<li>Bottom line: your mileage may vary with different tools, but there is no bug in YOURLS regarding that matter.</li>
</ul>
<a class="anch" href="#FAQ;noindex"><span>➤</span><h3 id="noindex">There is no index page at the root of the install</h3></a>
<ul>
<li>Indeed. It's intended. It's up to the user to make what they need. Some will redirect the root to a different place, some make a public interface for anyone to shorten links, some make a portfolio. You make it. See <a href="https://yourls.org/awesome">Awesome YOURLS</a> for inspiration!</li>
<li>If you want to make a public interface and run your own little bitly.com, there's a sample file provided as an example: <code>sample-public-front-page.txt</code>. This implies important issues to deal with: spam, performance and security. Read <a href="https://yourls.org/public">Public Shortening</a> for important information.</li>
</ul>
<a class="anch" href="#FAQ;lowercase"><span>➤</span><h3 id="lowercase">Uppercase letters in short URLs are eaten up, eg "<code>OmgOzh</code>" becomes "<code>mgzh</code>" !</h3></a>
<ul>
<li>Indeed. It's intended if you selected Base 36 (see above). Letters that don't belong to the character set, eg <code>@#!</code> or <code>ABC</code>, are removed.</li>
<li>If you want to force lowercase, you'll need a <a href="https://yourls.org/awesome">plugin</a>.</li>
</ul>
<a class="anch" href="#FAQ;feedback"><span>➤</span><h3 id="feedback">Feedback, feature requests and bug reporting</h3></a>
<ol>
<li>Please don't get in touch directly by mail or Twitter. <a href="https://yourls.org/support">Please</a>.</li>
<li>Read all the <a href="https://docs.yourls.org/">documentation</a>.</li>
<li>Search in all the <a href="https://yourls.org/issues">issues</a>, open and closed.</li>
<li>Eventually raise a new issue. To do so, please read the <a href="https://yourls.org/contribute">contribute guidelines</a>. Thanks!</li>
</ol>
</div>
<!-- More -->
<div id="MoreDiv" style="display: none;">
<a class="anch" href="#More;community"><span>➤</span><h2 id="community" class="first">Community</h2></a>
<p>YOURLS is open source, so the community of users plays a great role in its development, by contributing, helping others or giving feedback that helps improve the software.</p>
<a class="anch" href="#More;ressources"><span>➤</span><h3 id="ressources">Resources</h3></a>
<ul>
<li>The official <a href="http://blog.yourls.org">YOURLS blog</a>, for news, hints and showcase.</li>
<li>The <a href="https://docs.yourls.org/">documentations</a>: basic and advanced documentation, plugins, tips and more</li>
<li><a href="https://yourls.org/awesome">Awesome YOURLS</a> is a curated list of YOURLS resources, plugins, translations, guides and third-party tools.</li>
</ul>
<a class="anch" href="#More;showcase"><span>➤</span><h2 id="showcase">Showcase</h2></a>
<p>YOURLS is used by dozens of thousands of users : inviduals, anonymous, celebrities, universities, small teams, huge companies.</p>
<p>It is or has been used by Epic Games, the NASA, McLaren, Dreamhost and many more.</p>
<p>You will find several examples of YOURLS implementations on <a href="https://yourls.org/awesome">Awesome YOURLS</a>.</p>
<a class="anch" href="#More;frameworks"><span>➤</span><h2 id="frameworks">YOURLS and other platforms or frameworks</h2></a>
<p>Contributors have made YOURLS work with various platforms, programming languages, applications or tools : Laravel, Symfony, WordPress, Perl, Ruby, Android, iOS, you name it.</p>
<p>Head to <a href="https://yourls.org/awesome">Awesome YOURLS</a> and find the missing tool you didn't know you were needing.</p>
</div>
</div> <!-- content -->
</main>
</div> <!-- container -->
<div id="fade"></div>
<script type="text/javascript">
/* <![CDATA[*/
// Dynamically get tabs
function getTabs() {
var d = document.getElementById('Tabs');
var matches = d.innerHTML.match(/<li.* id="(.+?)Tab"/g);
var tabs = []
for (i in matches) {
tabs[i]= matches[i].replace(/<li.* id="/,'').replace('Tab"', '');
}
tabs = tabs.reverse();
return (tabs)
}
// Scroll to ?anchor
// window.location.hash
// Toggle tab display
function toggle(el) {
var hashes = el.toString().replace(/^.*?#/, '').split(';');
var target = hashes[0];
var anchor = hashes[1];
// If tab doesn't exist, exit
if( tabs.indexOf( target ) == -1 )
return;
for (var tab in tabs) {
// reinit tabs
document.getElementById(tabs[tab]+'Tab').className = 'Tab';
// reinit divs
document.getElementById(tabs[tab]+'Div').style.display= 'none';
}
// highlight & display target
document.getElementById(target+'Div').style.display = 'block';
document.getElementById(target+'Tab').className = 'SelectedTab';
randbg();
try { el.blur(); } catch(err) {}
// Try scrolling to anchor
try {
scrollTo(anchor);
} catch(err) { window.location.hash = target; }
}
// scroll to
function scrollTo(anchor){
window.scroll(0,findPos(document.getElementById(anchor)));
document.getElementById(anchor).classList.add('highlight');
}
// Get tab list
var tabs = getTabs();
// On page load/refresh display required tab
if (location.hash) {
toggle(location.hash);
}
// autoscroll on click
var anch=document.getElementsByClassName('anch');
var numanch=anch.length;
for(var i=0; i< numanch; i++){
anch[i].addEventListener('click', function(){scrollTo(this.hash.split(';')[1]);})
}
// Background fancyness
function randbg(){
var rndbg = [ 'bg_ants.png', 'bg_circles.png', 'bg_cross.png', 'bg_diag.png', 'bg_fuzzy.png', 'bg_fuzzy_bits.png', 'bg_yourls.png', 'bg_fuzzy_bits.png', 'bg_life.png', 'bg_boobs.png' ];
var bg = rndbg[ Math.floor( Math.random() * rndbg.length ) ];
document.body.style.background='#E3F3FF url(user/plugins/random-bg/img/'+bg+')';
};
randbg();
//Finds y value of given object
function findPos(obj) {
var curtop = 0;
if (obj.offsetParent) {
do {
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
curtop = curtop - 30;
return [curtop];
}
}
/* ]]> */
</script>
</body>
</html>