Topic-icon How to add location, follows and email to custom db fields (for google

Active Subscriptions:

None
9 years 10 months ago - 9 years 10 months ago #44892 by Geppie030
Hi Support,

Working with your extension now for 2 days and i'm really happy with it.
I want to add some extra fields in the dropdown (for google) so i can populate the database with some more info.
How can i add location, follows and email to the dropdown in profiles -> Import Configuration

i found google.php -> $this->providerFields and added for example:

'currentLocation' => 'Location',
'value.emails' => 'E-mail'

But this is not working.

Wondering if you can push me in the right direction.

Cheers
Last edit: 9 years 10 months ago by Geppie030.
The topic has been locked.
Support Specialist
I just checked out Google's User Profile information and it seems like there's quite a few new fields they've added there for us to retrieve. I've added it to our todo list for the 6.2 release to support more of the now-available fields.

As to your specific questions, to add email, you'd want to use "email" instead of value.emails. JFBConnect has special support for getting the user's Google account email address.

currentLocation sounds correct from what you've posted, though I haven't tested. Are you sure that value is set in your Google profile?

Finally, there isn't a "follows" profile field. Can you let me know what specific information you're trying to get from the list above?

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
9 years 10 months ago - 9 years 10 months ago #44941 by Geppie030
Hi Alex,

Thanks for the quick reply, really appreciate it.
What i want to get is the name, email, country and city (or location) and the interest (so what they follow, google +)
I managed name, email but is it also possible to get the info about the interest of the people?
To get the location where they live you have to use "placesLived[].value" right?

Geppie
Last edit: 9 years 10 months ago by Geppie030.
The topic has been locked.
Support Specialist
Geppie,
Wanted to get back to this post as well. I'm assuming you're still looking for this info, but if you've made any headway or have any other questions, just let me know.

For the placesLived, that is returned as an array from Google. Right now, our profile class doesn't support parsing out arrays, since the fields we currently support are all returned as discrete values. Some of the other networks already have support for array based fields, so we can easily help you add it. Before we do though, can you let me know how you want to store the field? Basically, if you want to use the drop-down to select the field to import, it means you'll likely want to pick a specific 'placesLived' array key. In that case, you'd need a discrete field in your database for placesLived0, placesLived1, placesLived2, etc for as many placesLived as you want to store. Most users will likely have 3 at most, so that would be a safe number to start with.

Alternatively, you could have one "placesLived" database value, and you simply store all the data returned from Google+ and parse it out later. That's harder to search, but may be all you need, depending on what you're doing with that information.

Hopefully that makes sense. If so, let me know how you'd want to store the data, and we can help you implement a quick bit of code that should do what you're looking for.

Finally, I can't see any way to get back the user's interests/+1's. If you see some documentation on how to do that, let me know, and we'll gladly investigate that further as well.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
Alex,

Again, thank you for your help. I will place a good review on extensions website of Joomla.
you said:
Alternatively, you could have one "placesLived" database value, and you simply store all the data returned from Google+ and parse it out later. That's harder to search, but may be all you need, depending on what you're doing with that information.

This is indeed all i need.
I placed 'placesLived[].value' => 'Location', inside profile/google.php
And selected this in the dropdown with a customdb field. But it's not working

It think as well that it is impossible to get the name of the groups/follows of the user.
it's not on the page: developers.google.com/+/api/latest/people
The topic has been locked.
Support Specialist
Here's the changes you should make to the /profile/google.php file:
In the providerFields variable at the top, add:
'placesLived' => 'PlacesLived'
At the bottom, around line 255, you'll see:
function get($path, $default = null)
    {
        if ($this->exists($path))
            $data = parent::get($path, $default);
        else
Update that as below, with the new block to parse out the placesLived data:
function get($path, $default = null)
    {
        if ($path == "placesLived")
        {
            $data = parent::get($path, $default);
            $val = array();

            if (is_object($data))
            {
                $data = (array) $data;
                if (count($data))
                {
                    foreach ($data as $place)
                    {
                        $val[] = $place->value;
                    }
                }
            }
            return implode(', ', $val);

        }

        if ($this->exists($path))
            $data = parent::get($path, $default);
        else
That code has been tested quickly, but obviously run a lot of tests on your own and let us know how that goes.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
Alex,

Great job, works perfect.
Thank you for the great support..1
The topic has been locked.
Support Specialist
Awesome! I'm glad to hear that got things going for your. If you have any other questions, issues or general feedback, just let us know.

Finally, if you haven't already, please consider leaving a rating and review for JFBConnect, or our support, on the Joomla Extension Directory. It certainly isn't required, but is very appreciated:
extensions.joomla.org/extensions/social-...ook-integration/7215

Thanks,
Alex
The topic has been locked.