|
PasswordlessAPI
Secure and passwordless API requests
Featured YOURLS allows API calls the old fashioned way, using username and password parameters (if your setup is private, obviously). If you're worried about sending your credentials into the wild, you can also make API calls using a secret signature token. Signature tokenYour secret signature token will be a string like 3002a61584 A secret signature token is unique, associated to one account, and can be used only for API requests. You will find it in the Tools page of your YOURLS install. NB: Can't see this signature on the Tools page? It's probably because your install is public. Therefore, you don't use a login and password to use it. Therefore there's no signature token to be used instead of a login/password pair. Usage of the signature tokenUse parameter signature in your API requests. Example: http://yoursite/yourls-api.php?signature=3002a61584&action=... Usage of a time limited signature tokenYou can create signature token valid for a short period only (one hour by default) First, craft the time limited signature token: <?php $timestamp = time(); $signature = md5( $timestamp . '3002a61584' ); // Replace with your own secret signature token. Example result: // $signature = "ed8d12124fc7916b00e3ecd7dc2c1d6a" ?> Now use parameters signature and timestamp in your API requests. Example: http://yoursite/yourls-api.php?timestamp=$timestamp&signature=$signature&action=... This URL would be valid for only 3600 seconds Reset your secret signature tokenIf for some reason you need to reset your signature (ie to generate a new one while making previous signature inoperative), simply modify the YOURLS_COOKIEKEY constant in your config.php
|
Is the signature token something you would share on your own site so others can use this?
Zenimot:
If you shared the key on your site (or anywhere), it would take only one malicious or foolhardy user to distribute the key to spammers.
A better solution would be to let users submit long url's and then shorten them using your server-side code.
I install YOURLS on http://mydomain.com/dir/ The script which call YOURLS is inside of http://mydomain.com/allfunction.php
I can install YOURLS successfully. I use call to passwordless api successfully. I use this as my internal url shortener service. I use call like this: http://mydomain.com/dir/api.php?action=shorturl&url=google.com&output=xml
However it is noted that -it will a bit dumb- if I call it using API when I call it from within same domain. How can i call it from within internal script without CURL to http://mydomain/dir/api.php ???
Thanks
Roy: on the same domain, include YOURLS to your script. Look at the source of the WordPress? plugin for an example.
How is Bit.ly using the api? The have it open right?
Bitly has nothing to do with this.
Is it possible to make a register optie that people get ask for a API Sig. And that they can use the api as wel?
So that there can be morgen signature's in use and they are in a SQL database.
These 2 sentences make no sense, sorry... I know clear English isn't easy for everybody but it's the only way we can communicate...
HI there, twitterfeed is asking for my short url api such as http://orto.me.uk/yourls-api.php?signature=[SECRET]&action= Is it secure to post this data into twitterfeed instead of using bit.ly? Sorry for the noob question...!
ortomed: this is exactly what this signature is for.
For Javascript I used something like this:
// MD5 Timestamp var sig = "yoursignature"; var timestamp = parseInt(new Date().getTime() / 1000); var sig_md5 = hex_md5(timestamp + sig); var signature = "timestamp="+timestamp+"&signature="+sig_md5;
Hello, I'm using Google translator!
I wonder if it is possible to use the tool below, Instant Custom Shorten, displaying the link in an alert box, but removing the link of Directors, for my administration and password protected, I would use the same initial link of the site. as used here < a href="javascript:void(location.href='http://mysite.com/index.php?&action=shorturl&url='+escape(location.href))"> Short Link < / a >
The tool is below this