Giter Site home page Giter Site logo

How to parse results? about api HOT 13 CLOSED

jsdelivr avatar jsdelivr commented on May 25, 2024
How to parse results?

from api.

Comments (13)

bebraw avatar bebraw commented on May 25, 2024

Can you describe what sort of result array you want?

from api.

MickeyKay avatar MickeyKay commented on May 25, 2024

Sure thing. For example, if I get the data at this URL for FontAwesome:
http://api.jsdelivr.com/v1/bootstrap/libraries/font-awesome/?fields=versions

I get the following output:

[
{
"versions": [
"4.0.3",
"4.0.2",
"4.0.1",
"4.0.0",
"3.2.1",
"3.2.0",
"3.1.1",
"3.1.0",
"3.0.2",
"3.0",
"2.0"
]
}
]

I can get that text in PHP, but my question is how do I turn that into a
PHP array that looks like this:

$versions = array(4.0.3, 4.0.2, 4.0.1, etc. . . )

An array upon which I can perform normal PHP operations and looping. Does
that make sense?

Thanks! Any help would be much appreciated :)

from api.

bebraw avatar bebraw commented on May 25, 2024

You probably should apply json_decode on the result. That will give you an array like above.

In JavaScript (Node.js) the operation you want would look like this:

var request = require('request');

request.get('http://api.jsdelivr.com/v1/bootstrap/libraries/font-awesome/?fields=versions',
    {
        json: true
    },
    function(err, res, data) {
        if(err) {
            return console.error(err);
        }

        var versions = data[0].versions;

        console.log(versions);
    }
);

You should be able to achieve something similar in PHP easily.

from api.

MickeyKay avatar MickeyKay commented on May 25, 2024

Awesome! I didn't even know that was JSON - learn something new every day.
Thanks again.

On Mon, Mar 24, 2014 at 11:46 PM, Juho Vepsäläinen <[email protected]

wrote:

You probably should apply json_decodehttp://be2.php.net/manual/en/function.json-decode.phpon the result. That will give you an array like above.

In JavaScript (Node.js) the operation you want would look like this (not
tested):

var request = require('request');
request.get('http://api.jsdelivr.com/v1/bootstrap/libraries/font-awesome/?fields=versions', {json: true},
function(err, res, data) {
if(err) {
return console.error(err);
}

    var versions = data[0].versions;

    console.log(versions);
});

You should be able to achieve something similar in PHP easily.

Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-38535256
.

from api.

bebraw avatar bebraw commented on May 25, 2024

Ok. I guess it's safe to close this issue.

If there are any other problems or you need something specific, just poke.

from api.

jimaek avatar jimaek commented on May 25, 2024

@MickeyKay Hey, your WordPress plugin very good.
Any chance you could a dropdown to allow users to choose what CDN to use and add us there too? :)

from api.

MickeyKay avatar MickeyKay commented on May 25, 2024

Not sure exactly what you mean? Can you clarify? Are you referring to
Better Font Awesome?

On Mon, Apr 21, 2014 at 11:05 AM, Dmitriy Akulov
[email protected]:

Hey, your WordPress plugin very good.
Any chance you could a dropdown to allow users to choose what CDN to use
and add us there too? :)

Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-40958944
.

from api.

jimaek avatar jimaek commented on May 25, 2024

Yes, Better Font Awesome. We too host FontAwesome http://www.jsdelivr.com/#!fontawesome
More info about jsDelivr https://hacks.mozilla.org/2014/03/jsdelivr-the-advanced-open-source-public-cdn/

You could add a dropdown allowing the user to select the CDN he wants to use to load FontAwesome. Let me know what you think :)

from api.

tomByrer avatar tomByrer commented on May 25, 2024

@MickeyKay jsDelivr uses the both the MaxCDN that BootstrapCDN uses & CloudFlare's CDN (plus a few extra PoPs in the CDN)

from api.

MickeyKay avatar MickeyKay commented on May 25, 2024

Ahhh, I see. Are there advantages to one vs. the other. This sounds like a
great feature to add, but I'd like to know what the reasons for/against are
before I start drawing up the code. Thanks!

On Mon, Apr 21, 2014 at 11:44 AM, tomByrer [email protected] wrote:

@MickeyKay https://github.com/MickeyKay jsDelivr uses the both the
MaxCDN that BootstrapCDN http://www.bootstrapcdn.com/extras/birthdayuses & CloudFlare's CDN (plus a few extra
PoPs in the CDN http://www.jsdelivr.com/network.php)

Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-40963049
.

from api.

jimaek avatar jimaek commented on May 25, 2024

It offers a choice to users which is a good thing :)
Other than that the main difference is in infrastructure. You can read the mozilla blog post and our readme here for more info https://github.com/jsdelivr/jsdelivr

from api.

MickeyKay avatar MickeyKay commented on May 25, 2024

Happy to report that Better Font Awesome plugin for WordPress (
https://wordpress.org/plugins/better-font-awesome) now offers the ability
to choose your CDN (jsDelivr or Bootstrap), with jsDelivr as the default!
Thanks for the great suggestions and all the help. Feel free to spread the
word about the plugin too :)

On Mon, Apr 21, 2014 at 3:29 PM, Dmitriy Akulov [email protected]:

It offers a choice to users which is a good thing :)
Other than that the main difference is in infrastructure. You can read the
mozilla blog post and our readme here for more info
https://github.com/jsdelivr/jsdelivr

Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-40984561
.

from api.

jimaek avatar jimaek commented on May 25, 2024

Thank you! Will do

from api.

Related Issues (20)

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.