Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when there is params within the url #7

Open
tanja84dk opened this issue Oct 8, 2021 · 6 comments
Open

Issue when there is params within the url #7

tanja84dk opened this issue Oct 8, 2021 · 6 comments
Assignees
Labels

Comments

@tanja84dk
Copy link

First of all thank you very much for the really great tool.

Unfortunally I have faced a small issue that I haven't found a way to get around.

I'm in the middle of making a personal tool for the game ogame ( only for myself atm to practice ) nd I have always loved json over xml

But unfortunally their API uses sometime params within the url Their API info and what I have noticed as soon that I add their urls there uses params then it fails where it work fine when its a link there don't have params

Does anyone have a idea how to work around that issue

@tanja84dk
Copy link
Author

tanja84dk commented Oct 17, 2021

Like trying with https://s180-en.ogame.gameforge.com/api/highscore.xml?category=1&type=1

And tested with curl that it does give the xml output directly but when adding the url to even your hosted site and my self hosted clone of your script to make it to Json right away it's failing and reports

"""
{"error":{"timestamp":"2021-10-17 03:27:37 EST","status":400,"title":"Bad Request","detail":"The URL you provided does not point to an valid XML feed. Please check that you entered the correct URL.","url":"/xml-to-json/?xml=https://s180-en.ogame.gameforge.com/api/highscore.xml?category=1&type=1"},"meta":{"version":"2.0.2","copyright":"Copyright 2011-2021 Fact Maven","link":"https://factmaven.com/","authors":["Ethan O'Sullivan","Edward Bebbington"]}}
"""

And it's only for the links where there is arguments in where it fails ( the output is from your site )

@GitBoudewijn
Copy link

GitBoudewijn commented Nov 18, 2021

This is just a basic question of URL encoding.

You can use something like encodeURIComponent() or just replace the ampersands (& / &) with %26:
https://api.factmaven.com/xml-to-json/?xml=https://s180-en.ogame.gameforge.com/api/highscore.xml?category=1%26type=1

@tanja84dk
Copy link
Author

Well thanks a lot for the answer but I have moved to another way to convert the xml links to json because there were no respons from the developer for a month and my project relyed on json format

@ethanosullivan
Copy link
Member

Hi folks, on the maker of the API. This has been a side project for me during my free time and I haven't gotten around to working on an implementation.

Thanks for showing a possible solution @GitBoudewijn, I'll have to explore investment out. If you're knowledgeable with PHP and want to give it a try and implement it in the code, happy to included and give you credit.

@ethanosullivan ethanosullivan self-assigned this Nov 18, 2021
@GitBoudewijn
Copy link

@ethanosullivan
The point is that this isn't a bug at all. Same as #6. The user is supposed to encode the query part of the URL. It's the same with any other API.

@tanja84dk
Copy link
Author

Well without any documentation and no way to url encode it on the website then I would classify it as a bug because the user have no way to know that

But sorry I wrote my goal was never to be looked so much down on for something there aren't documented

Please close this post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants