Skip to content

Loading…

Fix Piwik API to be used with AngularJS JSONP callback #4560

Closed
anonymous-piwik-user opened this Issue · 1 comment

2 participants

@anonymous-piwik-user

Hello everyone,

Piwik API is not compatible with $http.jsonp in AngularJS.

Docs: http://docs.angularjs.org/api/ng.$http

An API call like :


will be transform by AngularJS as something like:

```jsoncallback=angular.callbacks._0```

But the **Piwik API doesn't allow '.' in the jsoncallback parameter**.

To fix this bug, you just have to change:

/core/DataTable/Renderer/Json.php``` (line 111)

#!php
if (preg_match('/^[0-9a-zA-Z_]*$/D', $jsonCallback) > 0) {

By:

#!php
if (preg_match('/^[0-9a-zA-Z_.]*$/D', $jsonCallback) > 0) {

It would be great :)

Thanks

Romain

Keywords: angularjs,callback,jsonp

@mattab
Piwik Open Source Analytics member

In 96ac588: Fixes #4560: Piwik API can be used with AngularJS JSONP callback
Thanks for the report & fix!

@anonymous-piwik-user anonymous-piwik-user added this to the 2.1 - Piwik 2.1 milestone
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue
@mattab mattab Fixes #4560: Piwik API can be used with AngularJS JSONP callback
Thanks for the report & fix!
96ac588
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.