janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

Uncaught (in promise) Error: The "Get URL" request failed. #103

Closed janboddez closed 8 months ago

janboddez commented 8 months ago

Guess we can't catch errors this way if promises are involved. But I'm also not sure why it'd fail. 😅

janboddez commented 8 months ago
[12-Nov-2023 07:59:50 UTC] REST request: /share-on-mastodon/v1/url: {"post_id":"16484","_locale":"user"}(Header Absent)
[12-Nov-2023 07:59:50 UTC] REST result: /share-on-mastodon/v1/url: {"code":"rest_forbidden","message":"Sorry, you are not allowed to do that.","data":{"status":403}}(403) - [](User ID: 3)
janboddez commented 8 months ago

Nay have to with ...

if ( empty( $post_id ) || ! is_int( $post_id ) ) {
    return false;
}

If somehow $post_id turns out to not always be an int.

janboddez commented 8 months ago

Ah, I now see why. I use GET params (i.e., a query string) i.s.o. JSON ... at least in one place.