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

Multiple method in single API call #14272

Closed
AntoineWtrnd opened this issue Mar 26, 2019 · 7 comments
Closed

Multiple method in single API call #14272

AntoineWtrnd opened this issue Mar 26, 2019 · 7 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@AntoineWtrnd
Copy link

AntoineWtrnd commented Mar 26, 2019

Hello, i'm trying to figure out how can we call two method in a single API call using file_get_content.

The problem is, i'm trying to fetch all data for device model right now, which work great, but since that logo of brand icon can only be retrieve using getBrand, so i would like to get all this (getBrand and getModel) in this single call.

How can it be achieved ?

Thanks alot.

    <?php
    // this token is used to authenticate your API request.
    // You can get the token on the API page inside your Matomo interface
    $token_auth = 'xxxxxxx';

    // we call the REST API and request the 100 first keywords for the last month for the idsite=62
    $url2 = "https://xxxxxxxxxx";
    $url2 .= "?module=API&method=DevicesDetection.getBrand";
    $url2 .= "&idSite=2&period=month&date=today";
    $url2 .= "&format=JSON&filter_limit=10";
    $url2 .= "&token_auth=$token_auth&language=fr";

    $fetched2 = file_get_contents($url2);
    $content2 = json_decode($fetched2,true);




    foreach ($content2 as $row2) {

    $countryName2 = htmlspecialchars($row2["label"], ENT_QUOTES, 'UTF-8');
    $hits2 = $row2['nb_visits'];
    $logo2 = htmlspecialchars($row2["logo"], ENT_QUOTES, 'UTF-8');

    print("<tr><td>$logo2 <img src='xxxxxxxx/$logo2'> <b>$countryName2</b></td> <td>$hits2     visite(s)</td><br>\n</tr>");
    }
	
    if (!$content2) {
        print(" <p class='text-danger'><b>Aucune données disponible pour le moment.</b><br />Votre     site doit avoir été visité pour obtenir des résultats ici-même.</p>");
    }
	
								?>
@AntoineWtrnd
Copy link
Author

I pay someone who telling me the right way, 20$ by Paypal

@Findus23
Copy link
Member

Not too sure about it, but it seems like response from the getModel endpoint includes the brand name and the model name.

@AntoineWtrnd
Copy link
Author

AntoineWtrnd commented Mar 27, 2019

You are right.

It give brand and model, but not the brand icon...

That's why i need to fetch both...

Thanks

@tsteur
Copy link
Member

tsteur commented Mar 27, 2019

Also for reference you can issue multiple requests in one API call using the API.getBulkRequest method

@tsteur tsteur closed this as completed Mar 27, 2019
@tsteur
Copy link
Member

tsteur commented Mar 27, 2019

Hope that helps

@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Mar 27, 2019
@AntoineWtrnd
Copy link
Author

Wow, tsteur exactly what i needed.

As i said, i would pay 20$ for code script, so give me your Paypal will transfer 10$ since you provide me the informations.

@tsteur
Copy link
Member

tsteur commented Mar 27, 2019

Please donate it to any organisation of your choice ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants