Fix is.gd url shorted response handling
#904
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close https://github.com/Codeinwp/tweet-old-post-pro/issues/480
Summary
Added better service response handling and upgraded the URL to use the latest API endpoint.
Description
The posting mechanism added a message like that ends
Error, database insert failed. This was caused by the functionget_url, which tries to shorten the URL by usingis.gdservice.To replicate this issue you need a valid domain. The services work only with URLs that are available on the internet and are not on the blocklist (FYI: tastewp URLs are on the blacklist).
The main problem is that when services cannot process the URL, it will give something like this as a response:
Because the response error is
200, the code accepted the string without further verification.To solve this, I added a check to see that the response is a URL.
Any other response from the server will be treated as an error and logged:
There was also a report about the same issue for people who did not use the URL shortener https://github.com/Codeinwp/tweet-old-post-pro/issues/480#issuecomment-1896311145
I tested all the codes and could not reproduce them.
Testing
is.gdis not giving the URL. You can test with TasteWP or a local instance.is.gd, you will need a non-banned and online available instance.