Destination Server Returns Error Page when creating Short URL via API #3022
Replies: 1 comment 1 reply
-
I definitely cannot reproduce this, pretty much as I was expecting :) Code detailed below. Indeed if it used to work but does not any longer, as you say, something has changed. The YOURLS API hasn't changed for quite a long time and the URL you're trying to shorten doesn't contain UTF8 or fancy stuff which handling was improved or modified in latest releases, so it is fairly safe to say the change isn't within YOURLS. So : what has changed on your end ? It's either something on your script, at YOURLS level, at server level. I suggest you start over with your custom script and find the bug you've overlooked :) For reference : this code (ie the sample API call provided with YOURLS) <?php
$username = 'yourls';
$password = 'yourls';
$url = 'https://coraweb.sos.la.gov/CommercialSearch/CommercialSearchDetails.aspx?CharterID=964979_D0CA1BF42A';
$keyword = 'SLG';
$title = 'whatever';
$format = 'json';
$api_url = 'http://127.0.0.1/ozh.in/yourls-api.php';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $api_url );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, array(
'url' => $url,
'keyword' => $keyword,
'title' => $title,
'format' => $format,
'action' => 'shorturl',
'username' => $username,
'password' => $password
) );
$data = curl_exec($ch);
curl_close($ch);
echo $data; returns the expected JSON : {
"url":{
"keyword":"SLG",
"url":"https:\/\/coraweb.sos.la.gov\/CommercialSearch\/CommercialSearchDetails.aspx?CharterID=964979_D0CA1BF42A",
"title":"whatever",
"date":"2021-08-18 18:55:31",
"ip":"127.0.0.1"
},
"status":"success",
"message":"https:\/\/coraweb.sos.la.gov\/CommercialSearch\/CommercialS[...] added to database",
"title":"whatever",
"shorturl":"http:\/\/127.0.0.1\/ozh.in\/SLG",
"statusCode":200
} |
Beta Was this translation helpful? Give feedback.
-
Hi All,
I have a new issue with a script that we made several months ago and was working successfully. The goal is to create a short URL given a specific parameter. The issue seems to be in YOURLS fetch process of validating the long URL, and I don't know how to debug what's going on.
On this page, I can search for entity names in the Louisiana Secretary of State's database. We do this manually, find the entity we want, and then copy the CharterID field from the URL, to get this Long URL:
https://coraweb.sos.la.gov/CommercialSearch/CommercialSearchDetails.aspx?CharterID=964979_D0CA1BF42A
When I open the Long URL in my browser, I reach the expected page. Image for reference. I've successfully pasted the URL into incognito browsers and other browsers to test whether or not it may be blocked by CAPTCHA (the search function linked above is).
However, when creating a short URL using the YOURLS API, the URL changes from the long URL above to an error page. See the
url: url
value in the response below, where the page is ~/Error.aspxI've tried adding the title parameter to the POST to prevent YOURLS from fetching/validating the page, as described here, #2946, although that hasn't solved the issue. I still receive the URL as Error.aspx.
This setup worked for a while. By searching the YOURLS admin page for the domain name, I see we created 166 URLs, counting 453 clicks. If I search for Error.aspx, there's only 16 pages. So something changed.
Any tips on how to diagnose this?
POST Query (Edit to Add: I test this as GET request with the same results):
Response:
Beta Was this translation helpful? Give feedback.
All reactions