Giter Site home page Giter Site logo

factmaven / xml-to-json Goto Github PK

View Code? Open in Web Editor NEW
53.0 2.0 24.0 35 KB

Simple API that converts dynamic XML feeds to JSON through a URL or pasting the raw XML data. Made 100% in PHP.

Home Page: https://api.factmaven.com/xml-to-json

PHP 100.00%
xml json api converter convert-xml-to-json xml-to-json php xml-url xml-data json-api

xml-to-json's People

Contributors

ethanosullivan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xml-to-json's Issues

Resolve get_headers() timeout warning

A user reached out to me saying they had an issue converting an XML feed:

https://api.factmaven.com/xml-to-json/?xml=https://nitter.net/official_kep1er/rss

This is the error is gives:

<br />
<b>Warning</b>:  get_headers(https: //nitter.net/official_kep1er/rss): Failed to open stream: Connection timed out in <b>/home/factmaven/www/xml-to-json/index.php</b> on line <b>35</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type bool in <b>/home/factmaven/www/xml-to-json/index.php</b> on line <b>36</b><br />
{
    "error": {
        "timestamp": "2022-05-18 12:17:00 EST",
        "status": 0,
        "title": "",
        "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://nitter.net/official_kep1er/rss"
    },
    "meta": {
        "version": "2.0.2",
        "copyright": "Copyright 2011-2022 Fact Maven",
        "link": "https://factmaven.com/",
        "authors": [
            "Ethan O'Sullivan",
            "Edward Bebbington"
        ]
    }
}

It looks like there is some timeout issue with accessing the feed. I'll need to investigate further.

Add some Cache-Control / Expires headers?

Right now you don't return any Cache-Control and Expires headers so every time the browser makes a request it downloads the whole response again.

I'm not sure what kind of caching you do on your side but it's unlikely that the xml would change every couple of minutes so I would at least have some client side caching.

Otherwise maybe you could have an extra parameter like &cache=30 which controls the amount of minutes after which the response expires.

Issue when there is params within the url

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

Start tag expected, '&lt;' not found don't know what to do

When I try to use this url as xml input it will give me "Start tag expected, '&lt;' not found".
I am not too familiar with XML and some of this HTML syntax but it looks like there's a parsing error.

I believe <, a lesser than sign is being confused with an actual < or something. Can I fix this?

Bug with spaces?

The API is working fine with URLs until one of them has a space in it. (I replaced the space with %20 before sending it.) But, I get this error:

{"error":{"timestamp":"2022-06-18 07:41:55 EST","status":400,"title":"Failed Loading XML","detail":["Start tag expected, '<' not found"],"url":"/xml-to-json/?xml=https://boardgamegeek.com/xmlapi/search?search=ticket%20to%20ride"},"meta":{"version":"2.0.2","copyright":"Copyright 2011-2022 Fact Maven","link":"https://factmaven.com/","authors":["Ethan O'Sullivan","Edward Bebbington"]}}

Here's the URL I used: https://api.factmaven.com/xml-to-json/?xml=https://boardgamegeek.com/xmlapi/search?search=ticket%20to%20ride

More than possible that this is my issue, but read through the other issues and comments. Might be the same issue as this?

I tried it with some other URLs and seems to fail when there's a %20.
This works: https://api.factmaven.com/xml-to-json/?xml=https://boardgamegeek.com/xmlapi/search?search=Crossbows
This doesn't: https://api.factmaven.com/xml-to-json/?xml=https://boardgamegeek.com/xmlapi/search?search=Crossbows%20and

Thanks for any help you can offer!

Issue with special characters

The api returns an error when the xml contains characters such as ร‘.
Would it be possible to make it work for all characters?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.