joshp23 / YOURLS-Expiry

YOURLS plugin to define conditions under which links will expire - time and click limited links
GNU General Public License v3.0
35 stars 13 forks source link

Expiry in the API #44

Open bpmartin20 opened 9 months ago

bpmartin20 commented 9 months ago

Allegedly there's documentation on the API, but I haven't been able to find it. Please direct me if this has been answered somewhere, and accept my apologies.

Otherwise, if I'm using a programmatic interface to shorten URLs instead of the web interface, can I specify the expiration there?

In my case, I'm using Perl's WWW::Shorten::Yourls. The call there is: $ShortURL = $YourLS->shorten(longurl=>"https:/..."); Can I do something like: $ShortURL = $YourLS->shorten(longurl=>"https:/...", age=>35, agemod=>'days'); If so, what are the keys for the various parameters.

Again, my apologies if I missed this somewhere. I read through the code, but nothing stood out to me as a hook into the API.

bee10301 commented 7 months ago

I got the API issue too. I believe it's a bug. I checked the POST request from the UI, which sends: yourls-api.php?signature=sample&action=shorturl&format=json&expiry=clock&age=1&ageMod=day&url=https://sample So yes, it seems like it works with &age=1&ageMod=day. Then I found this pull request #42. I edited that line, and it worked fine in my case.

nyunity commented 1 month ago

Hello,

I tried https://xyz.com/yourls-api.php?signature=mysign&action=shorturl&format=json&expiry=clock&age=1&ageMod=day&url=test123.de

and I got json file without expiry:

{ "status": "success", "code": "", "message": "test123.de zur Datenbank hinzugefügt", "errorCode": "", "statusCode": 200, "url": { "keyword": "8is", "url": "test123.de", "title": "test123.de", "date": "2024-05-16 08:29:09", "ip": "x.x.x.x" }, "title": "test123.de", "shorturl": "https://xyz.com/8is" }

and the list of expire is empty :-(