API: how can I get the origin of the visitor specified by custom variable? - matomo

We're tracking our visitors by Piwik and I find it great.
However, I'm facing some difficulties using the APIs, especially with custom variables.
What I need to get is the very first origin of some registered user.
Imagine the flow:
an anonymous user comes to our website from somewhere (this is displayed on the frontend under the 'visitor log -> first visit -> from' section)
the user then registers (maybe) and starts using our website as an authenticated user, and we pass a custom variable called 'username' to Piwik.
How can I get the origin of the visitor - from where he came - programmatically? I don't actually know when the user first came to the website. I want to create some kind of a function which would take only the user's username and return his origin (ie. the URL of the site from which he came).
Any help appreciated.
Thank you!

Related

Facebook Taggable Friends

I am trying to get all the friends of the user currently signed in. I tried /me/friends but that didn't work as it returns only the users using my app already. I then tried https://graph.facebook.com/me/taggable_friends?access_token=somecodehere
In the browser it says
"To use taggable_friends on behalf of people who are not admins,
developers and testers of your app, your use of this endpoint must be
reviewed and approved by Facebook. To submit this feature for review
please read our documentation on reviewable features:
https://developers.facebook.com/docs/apps/review"
But when I do a GET (using Angular.js) on this URL with a valid access token using my application, it returns me a list of my friends, with their id, name, picture. Why is this happening? How can my app get the data if my browser cannot?
Also, the picture currently returned is too small. How can I get the email and larger picture of all my friends in this response?
Any help is highly appreciated.
PS: I am building a cordova app and getting access_token via CordovaOAuth.
taggable_friends works for you because it works without review for everyone with a role in the App (Admin/Developer/Tester). You only need to go through the review process if you want to go public with your App.
That beind said, taggable_friends is for tagging only, a larger picture is not neccessary for that and you definitely canĀ“t get their email. What would you do with the email of friends who did not even authorized your App? You would not be allowed to use those emails anyway. You can ONLY get the email of a Facebook user by authorizing that user with the email permission.
More information about getting access to friends: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

What is the Mirror API endpoint for account information so I can get a user's account timezone?

When a user authorizes with my Glassware they provide these permissions to my software:
Although it isn't lining up in the image, the more info is from the top "basic information about your account" permission. It mentions timezone which I would like to access to customize global event time stamps for display to people who don't grok GMT.
I am surprised I can't find the endpoint for this anywhere in the docs.
Anyone know where this might be, or is this a UI bug in the permissions dialog and really we can't see that information? Or perhaps is this only available to trusted partners like NYT and CNN, etc, and not to mere explorers.
I already tried variations on the timeline GET endpoint:
https://www.googleapis.com/mirror/v1/timeline
But substituting in various version of user/users and account/accounts and adding in the user id for a registered user, which I can get through this bit of Java code:
String userId = AuthUtil.getUserId(req);
Any help appreciated!
(Note: I won't give credit to anyone suggesting I get the user's location and use a Google API to reverse look up their location's timezone--see the issue tracker for problems with that approach not to mention I want the timezone the user set in their account not where they are)
The more information screen is coming from the https://www.googleapis.com/auth/userinfo.profile scope: with a token approved for this scope, you can send authorized requests to the userinfo endpoint:
GET https://www.googleapis.com/oauth2/v2/userinfo
Authorization: Bearer <OAUTH_2_TOKEN>
However, you will only be able to retrieve the timezone information if the user set it in their profile and allowed sharing.
In Java, retrieving this information is done with the OAuth2 API.

Invitation code and users database in Wordpress

I need your precious help. I'm working hard on organizing a contest linked to a wordpress site. That's the way it should work:
There's a contest. The user have to register as new user in WP (there's also the Facebook Connect/Open Graph) to enter the contest.
When a new user register himself, the system sends him an email: "Congratulations! You are a new user. Here there are some invitation codes (or links) to invite your friends. If they register here with the invitation code (or link), you'll receive a gift".
How can i do this workflow? I need to generate some codes (or links) every time a new user enter the WP site and assign them (linking those data to the users). I need to know if a new user (called B) comes to my site thanks to another user (called A), in order to give to A a gift.
Thank you guys.
You must make a frontend registration. Then, after user is registered you send him an email like www.yourdomain.com/register?uid=his_id(link to te registration form with his id as a parameter).
The when he passes the link to his friend B, friend B is registering and you check if there's a $_GET['uid']. It yes you add him a meta containing the id.
To make a front-end registeration, you should check this article.
For mail sending you could use wp_mail() function.
For passing params in the url and accessing you must be familiar with $_GET
For adding a meta for an user you must use the add_user_meta(). function.
The above steps are not necessarily difficult if you know basic PHP and willing to learn from Wordpress codex.
We created a plug called Cm Invitation Codes that allows you to assign codes per groups. This way you can know from which site each registration is coming and control also the number of user registration from a specific site. Try CM Invitation Code in WordPress Plugin Directory http://wordpress.org/extend/plugins/cm-invitation-codes/

How to add the user name in the url for a Chrome extension?

I am working on a chrome bookmarking extension with google app engine as the backend. I am the only user now but I thought that if in the future there are other users the url needs to include the user name for the extension to interact with the backend. So I was thinking to change
http://ting-1.appspot.com/useradminpage
to
http://ting-1.appspot.com/user_name/useradminpage
where "user_name" is the gmail user id.
But I looked at twitter url and I see that they have
http://twitter.com/#!/user_name/
What is the purpose of "#!"? Is my scheme good enough in this case?
The # in a URL signifies the 'fragment identifier'. Historically this has been used to identify a part of a document identified by an 'anchor' tag, but recently webapp developers have begun to use it to pass information about the page state to Javascript code running in the page. This is used because it's possible for Javascript code to modify the fragment of the current page without causing the page to reload - meaning it can update as you browse through the webapp, and go right back to where you were when you reload the page.
The fragment is not sent to the server when the browser loads a page, so Twitter's server just sees a request for twitter.com; it's up to the Javascript code in the page to examine the fragment and determine what to do after that.
In your particular case, assuming you're using the App Engine User service to authenticate users, you have a number of options for how to distinguish users in your URLs:
Use their email address. In theory this can change, and users may not want their address in a URL they will share. If the URLs are private, this is more or less a moot point.
Use their user_id. This is opaque and reveals no useful information about the user, so it's safe, but it's also meaningless and hard to remember.
Let users pick a nickname for their URLs, like Facebook and other services do, on a first-in, first-served basis.

Is it possible to access a user's Google +1 (Plus One) history via an API?

I would like to access a user's Google Plus One history
With +1 enabled, the history is saved in your Google profile and optionally can be displayed:
http://www.google.com/+1/button/
It is possible to access this programatically (once the user has given permission via normal Google Authentication and Authorization?)
I have only been able to find information for the API to add the button to sites.
You can allways try to parse the data used by G+ itself.
The G+ user profile has a tab with all public +1, that can be fetched with
https://plus.google.com/_/plusone/get?oid=<google-plus-id>
It seems to be related to JSON, but with some differences.
Check this out....
https://developers.google.com/+/history/
Dave,
I'm not sure about a user's history, but the count for particular URL is available via a JSON-RPC service (https://clients6.google.com/rpc). Here's a little post on how to:
http://www.johndyer.name/post/Getting-Counts-Twitter-Links-Facebook-Likes-Shares-and-Google-Plus-One-Buttons.aspx
I'm guessing that same service can get additional data, but I can't find any public documentation either.

Resources