Search code examples
matomo

Piwik from non-web app?


I'm trying to track a non-web app using Piwik (i.e., from a compiled .EXE written in C). From the tracking API Ref and other docs, I reversed-engineered (I think) the Piwik POST and sent it using TCP as shown below. However I always get a "Bad Request" Response. Any ideas on what's wrong?

--- THE REQUEST ----------------------------

POST /piwik/piwik.php HTTP/1.0
Content-Length: 60
<empty line>
idSite=1234&rec=1&url=http%3A%2F%2Fmyserver.com%2Findex.html

--- THE RESPONSE ---------------------------

HTTP/1.0 400 Bad Request
Date: Wed, 18 Nov 2015 15:25:18 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Content-Length: 123
Connection: close
Content-Type: text/html

--- END --------------------------------

More Details...

  • The latest version of Piwik is running on my web server.
  • I connect to it via TCP on socket 80 and send the POST data shown above.
  • All lines end with CR-LF.
  • I tried with and without URL-encoding of POST data.
  • I also tried a GET variant with URL encoding. Same results.

Solution

  • I gave up on the "POST" approach and went to "GET". It seems to work fine.

    --- THE REQUEST ----------------------------

    GET /piwik/piwik.php?idSite=1234&rec=1&url=http%3A%2F%2Fmyserver.com%2Findex.html HTTP/1.0
    <empty line>