Giter Club home page Giter Club logo

Comments (9)

emresaracoglu avatar emresaracoglu commented on May 20, 2024 1

Tyler, do you know?
You are great man! 😃 Thank you again

@MeekLogic

from cloudflare-php.

TylerVigario avatar TylerVigario commented on May 20, 2024

I don't believe it's currently possible, however, I am working on adding just that as it's a needed in a project of mine.

from cloudflare-php.

emresaracoglu avatar emresaracoglu commented on May 20, 2024

Can the information on this page help us?
Is it not possible to get data with CURL?

from cloudflare-php.

thellimist avatar thellimist commented on May 20, 2024

@emresaracoglu yes, it is possible to get analytics data by API. The link you provided has a curl example

curl -X GET "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/analytics/dashboard?since=2015-01-01T12:23:00Z&until=2015-01-02T12:23:00Z&continuous=true" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json"

from cloudflare-php.

emresaracoglu avatar emresaracoglu commented on May 20, 2024

I can get the data but there is a big problem this time :)
I do not know how to read a complicated JSON file.

I plan to use a JSON reader for this. Maybe this; JsonReader - @pcrov

How do I read in the best way for JSON?
for example; bandwidth in JSON

$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,"https://api.cloudflare.com/client/v4/zones/ZoneID/analytics/dashboard?since=2017-11-06T12:23:00Z&until=2017-11-07T12:23:00Z&continuous=true");
	curl_setopt($ch, CURLOPT_POST, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	
	$headers = [
		'X-Auth-Email: Email',
		'X-Auth-Key: Key',
		'Content-Type: application/json'
	];
	
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	$server_output = curl_exec ($ch);
	curl_close ($ch);

from cloudflare-php.

TylerVigario avatar TylerVigario commented on May 20, 2024

I've added getAnalyticsDashboard() to Zones

You can pull my fork until they add to a release - https://github.com/MeekLogic/cloudflare-php

from cloudflare-php.

emresaracoglu avatar emresaracoglu commented on May 20, 2024

@MeekLogic That's great work! Thank you for your time.
I have updated repository with your files

Could this connection be true?

$zones = new \Cloudflare\API\Endpoints\Zones($adapter);
	$analytics = $zones->getAnalyticsDashboard("bbea500d1b4ca31fd42d9af01950fd6");
	foreach ($analytics as $goster) {
		echo $goster['bandwidth'];
               //echo $goster['uncached'];
	}

from cloudflare-php.

TylerVigario avatar TylerVigario commented on May 20, 2024

You probably don't want a foreach unless you are looping through the "timeseries"

If you want to get bandwidth total should be something like this

$zones = new \Cloudflare\API\Endpoints\Zones($adapter);
$analytics = $zones->getAnalyticsDashboard("bbea500d1b4ca31fd42d9af01950fd6");

echo $analytics->totals->bandwidth->all;

from cloudflare-php.

IcyApril avatar IcyApril commented on May 20, 2024

Released in 1.0.6

from cloudflare-php.

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.