[ Index ] |
PHP Cross Reference of YOURLS |
[Summary view] [Print] [Text view]
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 3 <head> 4 <meta http-equiv="X-UA-Compatible" content="IE-9"/> 5 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 6 <title>YOURLS: Your Own URL Shortener</title> 7 <link href='https://fonts.googleapis.com/css?family=Fira+Sans:400,700' rel='stylesheet' type='text/css'> 8 <style type="text/css" media="screen"> 9 /* Default Style */ 10 body { 11 font-family: Verdana, Arial, sans-serif; 12 font-size: 12px; 13 color: #595441; 14 background:#E3F3FF; 15 margin-top:0px; 16 margin-bottom:30px; 17 } 18 p { 19 padding-left: 10px; 20 } 21 code { 22 background:#eaeaef; 23 padding:0 2px; 24 } 25 tt { 26 background:#ffc; 27 padding:0 2px; 28 } 29 pre tt { 30 display:block; 31 } 32 blockquote { 33 margin: 10px 20px 0px 20px; 34 padding: 10px; 35 border: 1px solid #8d8d8d; 36 background-color: #f5f5f5; 37 } 38 li { 39 margin-top: 20px; 40 } 41 ul li ul li { 42 margin-top: 10px; 43 } 44 a, a:active, a:link, a:visited { 45 color: #7ba7e4; 46 text-decoration: none; 47 } 48 a:hover { 49 color: #5577a5; 50 text-decoration: underline; 51 } 52 div.sshot { 53 } 54 div.sshot p { 55 zcolor:#5577a5; 56 zfont-size:90%; 57 } 58 div.sshot img { 59 margin-bottom:1em; 60 border:1px solid #2A85B3; 61 padding:10px; 62 border-radius:10px; 63 } 64 #fade { 65 position:absolute; background: #E3F3FF; width:100%; height:230px; top:0px; left:0px; z-index:-1; 66 background: -webkit-gradient(linear, left top, left bottom, from(rgba(227, 243, 255, 1)), to(rgba(227, 243, 255, 0))); 67 background: -moz-linear-gradient(top, rgba(227, 243, 255, 1), rgba(227, 243, 255, 0.1)); /* for firefox 3.6+ */ 68 } 69 /* Place Holder Style */ 70 #Container { 71 width: 850px; 72 margin-left: auto; 73 margin-right: auto; 74 z-index:1337; 75 } 76 #Content { 77 background: none repeat scroll 0 0 white; 78 border: 3px solid #2A85B3; 79 -moz-border-radius:20px; 80 -webkit-border-radius:20px; 81 border-radius: 20px; 82 margin-top:-13px; 83 min-height: 150px; 84 padding: 5px 20px 10px; 85 text-align: left; 86 z-index:2; 87 } 88 /* Title Style */ 89 h1{margin:0px} 90 #Container h1 a { 91 display:block; 92 font-family: 'Fira Sans', Verdana, Arial; 93 font-size: 32px; 94 font-weight: 700; 95 color: #2A85B3; 96 margin-top:0px; 97 margin-bottom: 0px; 98 background:transparent url(images/yourls-logo.svg) left 5px no-repeat; 99 background-size: 220px; 100 padding-top:15px; 101 height:80px; 102 padding-left:250px; 103 text-align:left; 104 } 105 h1 a:hover{text-decoration:none} 106 h1 a:hover span { 107 color: #88C0EB; 108 text-decoration:underline; 109 } 110 h2 { 111 font-family: 'Fira Sans', Verdana, Arial; 112 font-size: 22px; 113 font-weight: 700; 114 color: #5b87b4; 115 margin-top:50px; 116 } 117 h2.first{margin-top:10px} 118 h2:before { 119 content: '\00BB '; 120 color:#BFE0FE; 121 } 122 h3 { 123 font-family: 'Fira Sans', Verdana, Arial; 124 font-size: 18px; 125 font-weight: bold; 126 color: #73a4d6; 127 margin-top:2em; 128 } 129 h3:before { 130 content: '\203A '; 131 color:#BFE0FE; 132 } 133 a.anch span { 134 display:none; 135 } 136 .highlight { 137 animation-name: pulsedown; 138 animation-duration: 4s; 139 animation-iteration-count: 1; 140 } 141 @keyframes pulsedown { 142 0% {background-color: #FFFF00;} 143 100 {background-color: transparent;} 144 } 145 /* Tabs */ 146 ul#Tabs { 147 font-family: Verdana, Arial; 148 font-size: 13px; 149 font-weight: 400; 150 list-style-type: none; 151 padding-bottom: 28px; 152 border-bottom: 1px solid #2A85B3; 153 margin:0 30px 12px 30px; 154 z-index: 1; 155 } 156 #Tabs li.Tab { 157 float: right; 158 height: 23px; 159 background-color: #deedfb; 160 margin: 3px 0px 0px 5px; 161 border: 2px solid #2A85B3; 162 -webkit-border-top-left-radius: 10px; 163 -webkit-border-top-right-radius: 10px; 164 -moz-border-radius-topleft: 10px; 165 -moz-border-radius-topright: 10px; 166 border-top-left-radius: 10px; 167 border-top-right-radius: 10px; 168 } 169 #Tabs li.Tab a { 170 float: left; 171 display: block; 172 color: #666666; 173 text-decoration: none; 174 padding: 3px 5px; 175 } 176 #Tabs li.Tab a:hover { 177 background-color: #bfe0fe; 178 -webkit-border-top-left-radius: 10px; 179 -webkit-border-top-right-radius: 10px; 180 -moz-border-radius-topleft: 10px; 181 -moz-border-radius-topright: 10px; 182 border-top-left-radius: 10px; 183 border-top-right-radius: 10px; 184 } 185 /* Selected Tab */ 186 #Tabs li.SelectedTab { 187 float: right; 188 height: 24px; 189 background-color: #fff; 190 margin: 0px 0px 0px 5px; 191 border-top: 2px solid #2A85B3; 192 border-right: 2px solid #2A85B3; 193 border-left: 2px solid #2A85B3; 194 border-bottom: 6px solid #fff; 195 -webkit-border-top-left-radius: 10px; 196 -webkit-border-top-right-radius: 10px; 197 -moz-border-radius-topleft: 10px; 198 -moz-border-radius-topright: 10px; 199 border-top-left-radius: 10px; 200 border-top-right-radius: 10px; 201 } 202 #Tabs li.SelectedTab a { 203 float: left; 204 display: block; 205 color: #666666; 206 text-decoration: none; 207 padding: 5px; 208 cursor: default; 209 } 210 </style> 211 <!--[if IE]> <style>#fade{display:none}</style> <![endif]--> 212 </head> 213 <body> 214 <div id="fb-root"></div> 215 <div id="Container"> 216 217 <!-- Title --> 218 <header role="banner"> 219 <h1><a href="https://yourls.org/">YOURLS: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener</a></h1> 220 </header> 221 222 <main role="main"> 223 <!-- Tabs --> 224 <ul id="Tabs"> 225 <li id="MoreTab" class="Tab"><a href="#More" onclick="toggle(this);">More</a></li> 226 <li id="FAQTab" class="Tab"><a href="#FAQ" onclick="toggle(this);">FAQ</a></li> 227 <li id="APITab" class="Tab"><a href="#API" onclick="toggle(this);">API</a></li> 228 <li id="PluginsTab" class="Tab"><a href="#Plugins" onclick="toggle(this);">YOURLS plugins</a></li> 229 <li id="ConfigTab" class="Tab"><a href="#Config" onclick="toggle(this);">Config</a></li> 230 <li id="InstallTab" class="Tab"><a href="#Install" onclick="toggle(this);">Install/Upgrade</a></li> 231 <li id="AboutTab" class="SelectedTab"><a href="#About" onclick="toggle(this);">About</a></li> 232 </ul> 233 234 <!-- Content --> 235 <div id="Content"> 236 237 <!-- Index --> 238 <div id="AboutDiv"> 239 <a class="anch" href="#About;about"><span>➤</span><h2 id="about" class="first">About YOURLS</h2></a> 240 241 <a class="anch" href="#About;what"><span>➤</span><h3 id="what">What is YOURLS</h3></a> 242 <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> 243 244 <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> 245 246 <a class="anch" href="#About;features"><span>➤</span><h3 id="features">YOURLS Features</h3></a> 247 <ul> 248 <li><tt>Free</tt> and <tt>open-source</tt> software,</li> 249 <li><tt>Private</tt> (your links only) or <tt>Public</tt> (everybody can create short links, fine for an intranet),</li> 250 <li>Terrific <tt>Plugin</tt> architecture and dozens of <tt>plugins</tt> to easily implement new features,</li> 251 <li>Handy <tt>bookmarklets</tt> to easily shorten and share links,</li> 252 <li>Awesome <tt>stats</tt>: historical click reports, referrers tracking, visitors geo-location,</li> 253 <li>Developer <tt>API</tt> to integrate YOURLS into other applications,</li> 254 <li>Friendly <tt>installer</tt>,</li> 255 <li><tt>Sample files</tt> to create your own public interface and more !</li> 256 </ul> 257 258 <a class="anch" href="#About;screenshots"><span>➤</span><h3 id="screenshots">Screenshots</h3></a> 259 260 <div class="sshot"> 261 <p>Main admin dashboard</p> 262 <img src="images/admin-dashboard.gif" /> 263 264 <p>Stats for each short URL</p> 265 <img src="images/stats-anim.gif" /> 266 </div> 267 268 <a class="anch" href="#About;download"><span>➤</span><h2 id="download">Download</h2></a> 269 270 <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> 271 272 <a class="anch" href="#About;credits"><span>➤</span><h2 id="credits">Credits</h2></a> 273 274 <p>YOURLS is made by <a href="https://github.com/YOURLS/YOURLS/graphs/contributors">awesome people</a>.</p> 275 276 <p>Keep up to date: read the official <a href="https://yourls.org/blog">YOURLS Blog</a>.</p> 277 </div> 278 279 <!-- Installation Instructions --> 280 <div id="InstallDiv" style="display: none;"> 281 <a class="anch" href="#Install;fresh"><span>➤</span><h2 id="fresh" class='first'>Fresh Install</h2></a> 282 <ol> 283 <li>Unzip the YOURLS archive</li> 284 <li>Copy <code>user/config-sample.php</code> to <code>user/config.php</code></li> 285 <li>Open <code>user/config.php</code> with a raw text editor (like Notepad) and fill in the required settings</li> 286 <li>Upload the unzipped files to your domain <code>public_html</code> or <code>www</code> folder</li> 287 <li>Create a new database (see <a href="#Config" onclick="toggle(this);">Configuration</a> – you can also use an existing one)</li> 288 <li>Point your browser to <code>http://your-own-domain-here.com/admin/</code></li> 289 </ol> 290 <a class="anch" href="#Install;auto"><span>➤</span><h3 id="auto" class='first'>Install Guides</h3></a> 291 <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> 292 <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> 293 294 <a class="anch" href="#Install;upgrade"><span>➤</span><h2 id="upgrade">Upgrade</h2></a> 295 <ol> 296 <li><strong>Backup the database!</strong></li> 297 <li>Unzip the YOURLS archive</li> 298 <li>Upload files to your server, overwriting your existing install (this won't affect user files such as config or plugins)</li> 299 <li>Point your browser to <code>http://your-own-domain-here.com/admin/</code></li> 300 </ol> 301 302 </div> 303 304 <!-- Configuration Instructions --> 305 <div id="ConfigDiv" style="display: none;"> 306 <a class="anch" href="#Config;configuration"><span>➤</span><h2 id="configuration" class='first'>Configuration (in <code>user/config.php</code>)</h2></a> 307 <a class="anch" href="#Config;mysql"><span>➤</span><h3 id="mysql">MySQL settings</h3></a> 308 <ul> 309 <li><code>YOURLS_DB_USER</code><br/> 310 your MySQL username<br/> 311 <em>Example:</em> <tt>define( 'YOURLS_DB_USER', 'joe' );</tt></li> 312 <li><code>YOURLS_DB_PASS</code><br/> 313 your MySQL password<br/> 314 <em>Example:</em> <tt>define( 'YOURLS_DB_PASS', 'MySeCreTPaSsW0rd' );</tt></li> 315 <li><code>YOURLS_DB_NAME</code>: 316 The database name<br/> 317 <em>Example:</em> <tt>define( 'YOURLS_DB_NAME', 'yourls' );</tt></li> 318 <li><code>YOURLS_DB_HOST</code><br/> 319 The database host<br/> 320 <em>Example:</em> <tt>define( 'YOURLS_DB_HOST', 'localhost' );</tt></li> 321 <li><code>YOURLS_DB_PREFIX</code><br/> 322 The name prefix for all the tables YOURLS will need<br/> 323 <em>Example:</em> <tt>define( 'YOURLS_DB_PREFIX', 'yourls_' );</tt></li> 324 </ul> 325 326 <a class="anch" href="#Config;site"><span>➤</span><h3 id="site">Site options</h3></a> 327 <ul> 328 <li><code>YOURLS_SITE</code><br/> 329 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/> 330 <em>Example:</em> <tt>define( 'YOURLS_SITE', 'https://your-own-domain-here.com' );</tt></li> 331 <li><code>YOURLS_PRIVATE</code><br/> 332 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/> 333 <em>Example:</em> <tt>define( 'YOURLS_PRIVATE', true );</tt></li> 334 <li><code>YOURLS_UNIQUE_URLS</code><br/> 335 Allow multiple short URLs for a same long URL<br/> 336 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/> 337 <em>Example:</em> <tt>define( 'YOURLS_UNIQUE_URLS', true );</tt></li> 338 <li><code>YOURLS_COOKIEKEY</code><br/> 339 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/> 340 <em>Example:</em> <tt>define( 'YOURLS_COOKIEKEY', 'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm' );</tt></li> 341 <li><code>yourls_user_passwords</code><br/> 342 A list of username(s) and password(s) allowed to access the site if private<br/> 343 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/> 344 <em>Example:</em> <tt>'joe' => 'mypassword'</tt></li> 345 </ul> 346 347 <a class="anch" href="#Config;urlsettings"><span>➤</span><h3 id="urlsettings">URL Shortening settings</h3></a> 348 <ul> 349 <li><code>YOURLS_URL_CONVERT</code><br/> 350 URL shortening method: base <tt>36</tt> or <tt>62</tt>. See <a onclick="toggle(this);" href="#FAQ">FAQ</a> for more explanations</li> 351 <li><code>yourls_reserved_URL</code><br/> 352 A list of reserved keywords that won't be used as short URLs. Define here negative, unwanted or potentially misleading keywords<br/> 353 <em>Example:</em> <tt>'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick'</tt></li> 354 </ul> 355 356 <a class="anch" href="#Config;optional"><span>➤</span><h3 id="optional">Optional settings</h3></a> 357 <ul> 358 <li><code>YOURLS_PRIVATE_INFOS</code><br/> 359 If <code>YOURLS_PRIVATE</code> is set to <tt>true</tt>, you can still make stat pages public. To do so, define with:<br/> 360 <tt>define('YOURLS_PRIVATE_INFOS', false);</tt> 361 </li> 362 <li><code>YOURLS_PRIVATE_API</code><br/> 363 If <code>YOURLS_PRIVATE</code> is set to <tt>true</tt>, you can still make your API public. To do so, define with:<br/> 364 <tt>define('YOURLS_PRIVATE_API', false);</tt> 365 <li><code>YOURLS_NOSTATS</code><br/> 366 If <code>YOURLS_NOSTATS</code> is set to <tt>true</tt>, redirects won't be logged and there will be not stats available.<br/> 367 </li> 368 </ul> 369 370 <a class="anch" href="#Config;advanced"><span>➤</span><h3 id="advanced">Advanced settings</h3></a> 371 <ul> 372 <li>You can install YOURLS behind a firewall or a proxy: see <a href="https://yourls.org/proxy">Proxy Support</a></li> 373 <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> 374 <li>There are numerous tips and guides on the <a href="https://docs.yourls.org/">Documentation</a>, be sure to read them.</li> 375 </ul> 376 </div> 377 378 <!-- YOURLS plugins --> 379 <div id="PluginsDiv" style="display:none"> 380 <a class="anch" href="#Plugins;plugins-for-yourls"><span>➤</span><h2 id="plugins-for-yourls" class="first">Plugins for YOURLS</h2></a> 381 382 <a class="anch" href="#Plugins;plugins"><span>➤</span><h3 id="plugins">Plugins?</h3></a> 383 <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> 384 <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> 385 <p>There's a growing number of plugins available: check the <a href="https://yourls.org/awesome">Plugin list</a>.</p> 386 387 <a class="anch" href="#Plugins;documentation"><span>➤</span><h3 id="documentation">Documentation</h3></a> 388 <p>Several sample plugins are included in the archive. Read the source and learn the concept. It's easy and fun!</p> 389 <p>Check the <a href="https://yourls.org/pluginapi">plugin API documentation</a> to learn more</p> 390 391 </div> 392 393 <!-- API --> 394 <div id="APIDiv" style="display:none"> 395 <a class="anch" href="#API;yourls-api"><span>➤</span><h2 id="yourls-api" class="first">YOURLS' API</h2></a> 396 397 <a class="anch" href="#API;apifeatures"><span>➤</span><h3 id="apifeatures">Features</h3></a> 398 <ul> 399 <li>Generate or get existing short URLs, with sequential or custom keyword</li> 400 <li>Get some statistics about your links: top clicked links, least clicked links, newest links</li> 401 <li>Output format: JSON, XML, or simple raw text</li> 402 <li>Authentify either with login/password or using a secure passwordless mechanism</li> 403 </ul> 404 405 <a class="anch" href="#API;apiusage"><span>➤</span><h3 id="apiusage">Usage</h3></a> 406 <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> 407 <ul> 408 <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> 409 <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> 410 <li>With <tt>action = "shorturl"</tt> : 411 <ul> 412 <li>the <code>url</code> to shorten</li> 413 <li>optional <code>keyword</code> and <code>title</code> for custom short URLs</li> 414 <li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li> 415 </ul> 416 </li> 417 <li>With <tt>action = "expand"</tt> : 418 <ul> 419 <li>the <code>shorturl</code> to expand (can be either 'abc' or 'http://site/abc')</li> 420 <li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li> 421 </ul> 422 </li> 423 <li>With <tt>action = "url-stats"</tt> : 424 <ul> 425 <li>the <code>shorturl</code> for which to get stats (can be either 'abc' or 'http://site/abc')</li> 426 <li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt> or <tt>"xml"</tt></li> 427 </ul> 428 </li> 429 <li>With <tt>action = "stats"</tt> : 430 <ul> 431 <li>the <code>filter</code>: either <tt>"top"</tt>, <tt>"bottom"</tt> , <tt>"rand"</tt> or <tt>"last"</tt></li> 432 <li>the <code>limit</code> (maximum number of links to return)</li> 433 <li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt> or <tt>"xml"</tt></li> 434 </ul> 435 </li> 436 <li>With <tt>action = "db-stats"</tt> : 437 <ul> 438 <li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt> or <tt>"xml"</tt></li> 439 </ul> 440 </li> 441 <li>With <tt>action = "version"</tt> : 442 <ul> 443 <li>output <code>format</code>: either <tt>"jsonp"</tt>, <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li> 444 </ul> 445 </li> 446 </ul> 447 448 <a class="anch" href="#API;apiexample"><span>➤</span><h3 id="apiexample">Sample requests</h3></a> 449 <p>Example of a <tt>GET</tt> request with Javascript (using jQuery) to shorten a URL</p> 450 <pre><tt>var api_url = 'http://sho.rt/yourls-api.php'; 451 var response = $.get( api_url, { 452 username: "your_username", 453 password: "your_password", 454 action: "shorturl", 455 format: "json", 456 url: "http://ozh.org/" 457 }, 458 // callback function that will deal with the server response 459 function( data) { 460 // now do something with the data, for instance show new short URL: 461 alert(data.shorturl); 462 } 463 );</tt></pre> 464 465 <p>Example of a <tt>POST</tt> request with PHP to expand a short URL</p> 466 <pre><tt><?php 467 $username = 'your_username'; 468 $password = 'your_password'; 469 $api_url = 'http://sho.rt/yourls-api.php'; 470 471 // Init the CURL session 472 $ch = curl_init(); 473 curl_setopt($ch, CURLOPT_URL, $api_url); 474 curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result 475 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result 476 curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request 477 curl_setopt($ch, CURLOPT_POSTFIELDS, array( // Data to POST 478 'shorturl' => 'ozh', 479 'format' => 'json', 480 'action' => 'expand', 481 'username' => $username, 482 'password' => $password 483 )); 484 485 // Fetch and return content 486 $data = curl_exec($ch); 487 curl_close($ch); 488 489 // Do something with the result. Here, we echo the long URL 490 $data = json_decode( $data ); 491 echo $data->longurl;</tt></pre> 492 493 <a class="anch" href="#API;apireturn"><span>➤</span><h3 id="apireturn">Sample returns</h3></a> 494 <p>Sample return in JSON format for the <code>shorturl</code> action</p> 495 <pre><tt>{ 496 "url": { 497 "keyword": "ozh", 498 "url": "http:\/\/ozh.org", 499 "title": "Ozh RICHARD \u00ab ozh.org", 500 "date": "2014-10-24 16:01:39", 501 "ip": "127.0.0.1" 502 }, 503 "status": "success", 504 "message": "http:\/\/ozh.org added to database", 505 "title": "Ozh RICHARD \u00ab ozh.org", 506 "shorturl": "http:\/\/sho.rt\/1f", 507 "statusCode": "200" 508 }</tt></pre> 509 510 <p>Sample return in XML format for the <code>expand</code> action</p> 511 <pre><tt><result> 512 <keyword>ozh</keyword> 513 <shorturl>http://sho.rt/ozh</shorturl> 514 <longurl>http://ozh.org/</longurl> 515 <message>success</message> 516 <statusCode>200</statusCode> 517 </result></tt></pre> 518 519 <a class="anch" href="#API;apisample"><span>➤</span><h3 id="apisample">Sample file</h3></a> 520 <p>There's a sample PHP file included that serves as an example on how to play with the API</p> 521 522 <a class="anch" href="#API;expand_api"><span>➤</span><h3 id="expand_api">Expand the API</h3></a> 523 <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> 524 525 </div> 526 527 528 <!-- FAQ Instructions --> 529 <div id="FAQDiv" style="display: none;"> 530 <a class="anch" href="#FAQ;theFAQ"><span>➤</span><h2 id="theFAQ" class="first">FAQ</h2></a> 531 532 <a class="anch" href="#FAQ;requirement"><span>➤</span><h3 id="requirement">Server requirements and recommendations</h3></a> 533 <ol> 534 <li>We recommend <strong>PHP 7.4</strong> or above</li> 535 <li>You will need at least <strong>MYSQL 5</strong></li> 536 <li>A web server with <strong>mod_rewrite</strong> enabled<br/> 537 <em>Note</em>: YOURLS can also run on <a href="https://docs.yourls.org/guide/server-configuration.html#nginx">Nginx</a>, 538 <a href="https://github.com/lylebrown/YOURLS-Cherokee">Cherokee</a> and <a href="https://github.com/YOURLS/awesome-yourls#installation-guides">more</a> !</li> 539 <li><strong>HTTPS</strong> support</li> 540 <li>PHP <a href="http://www.php.net/curl">CURL extension</a> installed if you plan on playing with the API</li> 541 </ol> 542 543 <a class="anch" href="#FAQ;limitations"><span>➤</span><h3 id="limitations">Limitations</h3></a> 544 <ul> 545 <li>Maximum length of custom keyword is <strong>100 characters</strong></li> 546 <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> 547 </ul> 548 549 <a class="anch" href="#FAQ;base3662"><span>➤</span><h3 id="base3662">Difference Between Base 36 And Base 62 Encoding</h3></a> 550 <ul> 551 <li>Base 36 encoding uses <code>0123456789abcdefghijklmnopqrstuvwxyz</code> for short URLs</li> 552 <li>Base 62 encoding uses <code>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</code></li> 553 <li>Stick to one setting, don't change after you've created links as it will change all your short URLs!</li> 554 <li>Base 36 is the default and should be picked if you're not sure.</li> 555 </ul> 556 557 <a class="anch" href="#FAQ;shortdomain"><span>➤</span><h3 id="shortdomain">Getting a short domain name for your YOURLS install</h3></a> 558 <ul> 559 <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> 560 <li><a href="http://domai.nr/">Domainr</a> is a fun search tool that might inspire and help you</li> 561 <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> 562 </ul> 563 564 <a class="anch" href="#FAQ;htaccess"><span>➤</span><h3 id="htaccess">YOURLS needs its own .htaccess</h3></a> 565 <ul> 566 <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> 567 <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> 568 </ul> 569 570 <a class="anch" href="#FAQ;does404"><span>➤</span><h3 id="does404">If YOURLS generates 404 for your short URLs</h3></a> 571 <ul> 572 <li>Make sure <strong>mod_rewrite</strong> is enabled with your Apache server</li> 573 <li>Make sure your .htaccess file looks like <a href="https://yourls.org/htaccess">this one</a></li> 574 <li>Check that your server Apache configuration allows use of .htaccess (<tt>AllowOverride All</tt> directive, ask your server admin)</li> 575 <li>Eventually, refer to <a href="https://yourls.org/support">Troubleshooting first steps</a>.</li> 576 </ul> 577 578 <a class="anch" href="#FAQ;sequential"><span>➤</span><h3 id="sequential">Random versus sequential short URLs</h3></a> 579 <ul> 580 <li>Out of the box, YOURLS generates sequential short URLS (ie <code>ab31</code>, then <code>ab32</code> and so on)</li> 581 <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> 582 </ul> 583 584 <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> 585 <ul> 586 <li>Out of the box, YOURLS updates traffic stats every time a short URL is requested. Period.</li> 587 <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> 588 <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> 589 <li>Bottom line: your mileage may vary with different tools, but there is no bug in YOURLS regarding that matter.</li> 590 </ul> 591 592 <a class="anch" href="#FAQ;noindex"><span>➤</span><h3 id="noindex">There is no index page at the root of the install</h3></a> 593 <ul> 594 <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> 595 <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> 596 </ul> 597 598 <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> 599 <ul> 600 <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> 601 <li>If you want to force lowercase, you'll need a <a href="https://yourls.org/awesome">plugin</a>.</li> 602 </ul> 603 604 <a class="anch" href="#FAQ;feedback"><span>➤</span><h3 id="feedback">Feedback, feature requests and bug reporting</h3></a> 605 <ol> 606 <li>Please don't get in touch directly by mail or Twitter. <a href="https://yourls.org/support">Please</a>.</li> 607 <li>Read all the <a href="https://docs.yourls.org/">documentation</a>.</li> 608 <li>Search in all the <a href="https://yourls.org/issues">issues</a>, open and closed.</li> 609 <li>Eventually raise a new issue. To do so, please read the <a href="https://yourls.org/contribute">contribute guidelines</a>. Thanks!</li> 610 </ol> 611 612 </div> 613 614 615 <!-- More --> 616 <div id="MoreDiv" style="display: none;"> 617 618 <a class="anch" href="#More;community"><span>➤</span><h2 id="community" class="first">Community</h2></a> 619 620 <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> 621 622 <a class="anch" href="#More;ressources"><span>➤</span><h3 id="ressources">Resources</h3></a> 623 <ul> 624 <li>The official <a href="http://blog.yourls.org">YOURLS blog</a>, for news, hints and showcase.</li> 625 <li>The <a href="https://docs.yourls.org/">documentations</a>: basic and advanced documentation, plugins, tips and more</li> 626 <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> 627 </ul> 628 629 <a class="anch" href="#More;showcase"><span>➤</span><h2 id="showcase">Showcase</h2></a> 630 631 <p>YOURLS is used by dozens of thousands of users : inviduals, anonymous, celebrities, universities, small teams, huge companies.</p> 632 <p>It is or has been used by Epic Games, the NASA, McLaren, Dreamhost and many more.</p> 633 <p>You will find several examples of YOURLS implementations on <a href="https://yourls.org/awesome">Awesome YOURLS</a>.</p> 634 635 <a class="anch" href="#More;frameworks"><span>➤</span><h2 id="frameworks">YOURLS and other platforms or frameworks</h2></a> 636 637 <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> 638 <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> 639 640 641 </div> 642 </div> <!-- content --> 643 </main> 644 </div> <!-- container --> 645 646 <div id="fade"></div> 647 648 <script type="text/javascript"> 649 /* <![CDATA[*/ 650 // Dynamically get tabs 651 function getTabs() { 652 var d = document.getElementById('Tabs'); 653 var matches = d.innerHTML.match(/<li.* id="(.+?)Tab"/g); 654 var tabs = [] 655 for (i in matches) { 656 tabs[i]= matches[i].replace(/<li.* id="/,'').replace('Tab"', ''); 657 } 658 tabs = tabs.reverse(); 659 return (tabs) 660 } 661 // Scroll to ?anchor 662 // window.location.hash 663 664 // Toggle tab display 665 function toggle(el) { 666 var hashes = el.toString().replace(/^.*?#/, '').split(';'); 667 var target = hashes[0]; 668 var anchor = hashes[1]; 669 // If tab doesn't exist, exit 670 if( tabs.indexOf( target ) == -1 ) 671 return; 672 for (var tab in tabs) { 673 // reinit tabs 674 document.getElementById(tabs[tab]+'Tab').className = 'Tab'; 675 // reinit divs 676 document.getElementById(tabs[tab]+'Div').style.display= 'none'; 677 } 678 // highlight & display target 679 document.getElementById(target+'Div').style.display = 'block'; 680 document.getElementById(target+'Tab').className = 'SelectedTab'; 681 randbg(); 682 try { el.blur(); } catch(err) {} 683 // Try scrolling to anchor 684 try { 685 scrollTo(anchor); 686 } catch(err) { window.location.hash = target; } 687 } 688 // scroll to 689 function scrollTo(anchor){ 690 window.scroll(0,findPos(document.getElementById(anchor))); 691 document.getElementById(anchor).classList.add('highlight'); 692 } 693 // Get tab list 694 var tabs = getTabs(); 695 // On page load/refresh display required tab 696 if (location.hash) { 697 toggle(location.hash); 698 } 699 // autoscroll on click 700 var anch=document.getElementsByClassName('anch'); 701 var numanch=anch.length; 702 for(var i=0; i< numanch; i++){ 703 anch[i].addEventListener('click', function(){scrollTo(this.hash.split(';')[1]);}) 704 } 705 // Background fancyness 706 function randbg(){ 707 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' ]; 708 var bg = rndbg[ Math.floor( Math.random() * rndbg.length ) ]; 709 document.body.style.background='#E3F3FF url(user/plugins/random-bg/img/'+bg+')'; 710 }; 711 randbg(); 712 //Finds y value of given object 713 function findPos(obj) { 714 var curtop = 0; 715 if (obj.offsetParent) { 716 do { 717 curtop += obj.offsetTop; 718 } while (obj = obj.offsetParent); 719 curtop = curtop - 30; 720 return [curtop]; 721 } 722 } 723 /* ]]> */ 724 </script> 725 726 727 </body> 728 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Jan 21 05:10:11 2025 | Cross-referenced by PHPXref 0.7.1 |