Matomo's Live API not respecting date - matomo

When I use Matomo's Live API for getting the user's profile with getVisitorProfile(), the passed in date is ignored.
curl -N -i -X POST -d 'token_auth=xxxlanguage=en&format=json&module=API&method=Live.getVisitorProfile&idSite=1&date=yesterday&period=day&segment=eventCategory==MediaVideo&visitorId=xxx' https://myurl.matomo.cloud/index.php
Triggering this command I get all last visits and not the requested time period. Is it a bug or meant to be? If it is intentionally, what would be the right query or method?

The Live.getVisitorProfile in the Matomo Reporting API does not have an option for date, the only options it accepts are idSite, visitorId = '', segment = '', limitVisits = ''
You can see what options are available for the Live API in the Reporting API Reference docs here: https://developer.matomo.org/api-reference/reporting-api#Live

Related

How do I register a Go To Webinar attendee to a specific session using their API V2?

OK so...through a custom form, I am successfully registering attendees to Go To Webinar but am blocked if there are multiple sessions of the same webinar. Currently, I am returning scheduled sessions to populate our dropdown menu (response shown below) but am challenged with passing back sessionKey with the registration payload. Has anyone successfully done this? Help! I've also put in an inquiry with GTW so will let folks know what I hear if others are struggling with this also. Thanks!
[{
webinarKey: xxxxxxxxxxxxxxxxx,
registrantsAttended: 0,
webinarID: "xxxxxxx",
sessionKey: 666666,
startTime: "2020-05-06T19:27:54Z",
endTime: "2020-05-06T20:01:13Z"
},
{
webinarKey: xxxxxxxxxxxxxxxxx,
registrantsAttended: 0,
webinarID: "xxxxxxx",
sessionKey: 777777,
startTime: "2020-05-07T19:26:08Z",
endTime: "2020-05-07T19:26:43Z"
}]
Populate a list for the webpage visitor using Scheduled
webinars
An interested individual selects a webinar from the list
and you submit their details using Create registrant
For step 2 you should also know the following:
To use the second version of the api you must pass the header value
'Accept: application/vnd.citrix.g2wapi-v1.1+json'
instead of 'Accept: application/json'.
Leaving this header out results in the first version of the API call.

clickhouse data insertion through API

I can get data from the clickhouse database using get method,
Similarly i want to insert data using post method .
Is their anyway to do like that
Modification of data in HTTP interface is allowed using POST method only.
Check out example given below on Clickhouse official documentation.
echo 'INSERT INTO t VALUES (1),(2),(3)' | curl 'http://localhost:8123/' --data-binary #-
https://clickhouse.yandex/docs/en/interfaces/http_interface/
Edit With Post Image.
Screenshot of postman and clickhouse client after insert
Try this:
Initially, change <readonly> Tag in user.xml of click house-server from read-only mode to read & write mode by changing <readonly> tag value to 0(zero).
Url:http://localhost:8123/?query=INSERT%20INTO%20db_name.table_name%20FORMAT%20Values
Body: ('1','2','3') // Body should be in tuple format.
Refer:https://clickhouse-docs.readthedocs.io/en/latest/settings/query_complexity.html#readonly

Quickbook No apptoken detected; (PHP)errorCode=003102; statusCode=401

I am new in quickbooks API implementation, I am always getting one error No apptoken detected; errorCode=003102; statusCode=401 when I am doing API call for customer add etc.
I am giving my steps, please look over that.
My sandbox info like that
Consumer Key: qyprdffbBBInX4a82jG73Mreyy96tC
Consumer Secret: IgpJzJrYvb9FmmdB7A0ECDGHG62Cp7dqVWjfMTvU
Access Token: qyprdlo3WrK0KhGZMTeA857AuKiVy2eaAmpXsRvG3jycYaMQ
Access Token Secret: TdPGpcUI8AiAdWFiCyb8jAAygH16bzU7VRGaspx4
I am Using PHP.
First I have generated oauth_signature.
$URL =
rawurlencode('https://sandbox-quickbooks.api.intuit.com/v3/company/408554291/customer');
$method = 'POST'; $parameter =
rawurlencode('oauth_consumer_key=qyprdffbBBInX4a82jG73Mreyy96tC&oauth_nonce=BlyqIBbv3R4T0P4qglAv1RjoYisMZk1449659733&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1449659733&oauth_token=qyprdlo3WrK0KhGZMTeA857AuKiVy2eaAmpXsRvG3jycYaMQ&oauth_version=1.0');
$ukey =
rawurlencode('IgpJzJrYvb9FmmdB7A0ECDGHG62Cp7dqVWjfMTvU').'&'.rawurlencode('TdPGpcUI8AiAdWFiCyb8jAAygH16bzU7VRGaspx4');
$hasmac = hash_hmac("sha1", $BaseURL,$ukey,1);
and My oauth_signature is jZ8JhECy/e0kpPbUdZp/o/EUC7U=
When i call API with this oauth_signature, i am getting Error 'No apptoken detected; errorCode=003102; statusCode=401'
My CURL call like this
curl -X POST -H 'Content-Type: application/json, Authorization: OAuth
oauth_token=qyprdlo3WrK0KhGZMTeA857AuKiVy2eaAmpXsRvG3jycYaMQ,oauth_consumer_key=qyprdffbBBInX4a82jG73Mreyy96tC,oauth_signature_method=HMAC-SHA1,oauth_timestamp=1449659733,oauth_version=1.0,oauth_nonce=BlyqIBbv3R4T0P4qglAv1RjoYisMZk1449659733,oauth_signature=jZ8JhECy/e0kpPbUdZp/o/EUC7U='
-d '{"data": [{"BillAddr":{"Line1":"86 A Topsia","City":"Kolkata","Country":"India","CountrySubDivisionCode":"WB","PostalCode":"700102"},"Title":"Mr.","GivenName":"ApurbaK","MiddleName":"Kumar","FamilyName":"ApurbaK","PrimaryPhone":{"FreeFormNumber":"564545465"},"PrimaryEmailAddr":{"Address":"apurbahazra12#navsoft.in"}}]}'
'https://sandbox-quickbooks.api.intuit.com/v3/company/408554291/customer'
Please look over that.
Thanks,
Apurba
Firstly, you don't want to be doing this yourself -- use a library. OAuth is complex, and implementing it yourself is going to be a hairy process, rife with errors.
Go grab a library:
https://github.com/consolibyte/quickbooks-php
Follow the quick-start guide linked there, and benefit from the examples:
https://github.com/consolibyte/quickbooks-php/tree/master/docs/partner_platform/example_app_ipp_v3
With that said, if you do decide to write it yourself, make sure you follow the OAuth spec:
https://www.rfc-editor.org/rfc/rfc5849
So far, the issues I immediately see with your implementation are:
You can't hard-code the timestamp like this: &oauth_timestamp=1449659733 The timestamp should be ever-changing, and set to the currenty timestamp.
You can't hard-code a nonce like this: &oauth_nonce=BlyqIBbv3R4T0P4qglAv1RjoYisMZk1449659733 The nonce has to change with every single request so this is going to fail after your first request.
You haven't normalized your request parameters / sorted them, per the spec.
This is the incorrect way to specify multiple headers with cURL: -H 'Content-Type: application/json, Authorization: OAuth .... Please see the cURL docs: http://curl.haxx.se/docs/manpage.html#-H
In the code you posted, you haven't actually set $BaseURL anywhere, so right now you're signing an empty string (unless you forgot to paste some code somewhere?)
What is $ukey set to? It doesn't appear to be defined in your code anywhere (did you forget to paste some code in?)

API : Ticker info

The Coinbase Exchange API: ticker GET /products/<product-id>/ticker only provides the last close. In order to place a market order, I need the best ask and bid (based on the side) price. Almost all exchanges provide this with their ticker API, so I am little surprised coinbase doesn't.
What am I missing? Is there any way I can get that information.
You can use the Order Book endpoint: GET /products/<product-id>/book to get that information. Further details are available here.
Doing it with rest template, java. The end point to hit is:
$ while true ; do curl http://api.pro.coinbase.com/products/BTC-USD/ticker ; echo ; done
Make sure, you use https. http will return nothing
while true ; do curl http://api.pro.coinbase.com/products/BTC-USD/ticker ; echo ; done

How do I delete all cards that belong to my app?

I'm trying to simply delete a few cards that were created by my app. However, it appears as though the list() method cycles through every single card in the entire user's timeline.
My code below is slightly modified from the example in the documentation under the timeline list. When I attempted to use this, it accidentally looped through every card in my timeline using up my entire 1,000 / day quota in just a few seconds before the operation timed out.
def delete_previous_cards(self):
"""
This cleans up any cards that may have been leftover.
"""
result = []
request = self.mirror_service.timeline().list()
while request:
try:
timeline_items = request.execute()
result.extend(timeline_items.get('items', []))
request = self.mirror_service.timeline().list_next(request, timeline_items)
except errors.HttpError, error:
print 'An error occurred: %s' % error
break
for item in result:
item_id = item['id']
self.mirror_service.timeline().delete(id=item_id).execute()
What's the best way to efficiently delete the cards created by my app?
There's a JavaScript based tool that an Explorer wrote for just this purpose: Glass Cleaner.
It looks to me like the Python example is missing any concept of a pageToken, most of the other language examples have a nextPageToken and loop until the response does not have a nextPageToken. If you keep requesting the first page over and over even if you only have three cards you will quickly exhaust your API quota.
The rest of this answer is general information about list and delete and some curl commands you can safely experiment with that won't loop and exhaust your quota quite as quickly. Make special note of the nextPageToken property in the returned JSON from list commands ...
LIST and DELETE are weird and don't follow the documentation exactly in my experience.
Here is a sample CURL command for List.
curl -x http://localhost:5671 -H "Authorization: Bearer YOUR_TOKEN_HERE"
https://www.googleapis.com/mirror/v1/timeline
It returns 10 items for the user and app that are associated with the token.
It includes deleted items (isDeleted set to true) but does not show the isDeleted property in the output JSON. This is weird.
If you modify it slightly:
curl -x http://localhost:5671 -H "Authorization: Bearer YOUR_TOKEN_HERE"
https://www.googleapis.com/mirror/v1/timeline?isDeleted=true
(note the trailing parameter) now you get the same list but the output JSON includes the isDeleted property. The lesson for me here is you should probably be requesting isDeleted=false for looping delete requests.
To delete an item you can do this:
curl -x http://localhost:5671 -H "Authorization: Bearer YOUR_TOKEN_HERE"
-H "Content-Type: application/json" -v -X DELETE
https://www.googleapis.com/mirror/v1/timeline/ID_OF_A_TIMELINE_CARD
Note you have to use an actual id from a card you got from a list command at the end. Grab one from a list command above.
When you do a successful DELETE the response is a 204, which in a RESTful world can indicate delete success.
Then if you do a subsequent list as in the first example above the item will come right back and not be marked as deleted because the isDeleted property is missing.
Pages seem to be 10 in size, but I guess that could change, since I didn't find that documented anywhere.
nextPageToken values seem to frequently have identical beginnings and ends, and they are very long strings, so it can be confusing to look at them and you might inadvertently think they are identical when they are not, lesson here is to compare very carefully in the middle.
Maybe those curl commands help you experiment when your API quota comes back, and I would experiment with testing for a null or empty string nextPageToken to tell you when to exit your loop. The equivalent java code is:
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
Good luck, and great question.

Resources