Opening profile dialog to request friendship

1 view
Skip to first unread message

Resseguie

unread,
Nov 13, 2009, 4:28:42 PM11/13/09
to Google Friend Connect Developer Forum
When you click on a profile picture in the members gadget and on
several of the sample sites (like http://www.ossamples.com/api/), a
dialog opens with profile information for that user and a link to
request friendship. What do you call to get that dialog? In the link
above, the href for the link is just the PROFILE_URL and the page
refreshes and then the dialog opens. But I don't see what's causing
that to happen.

thanks,
David

Bob Aman

unread,
Nov 13, 2009, 4:58:59 PM11/13/09
to google-friend-co...@googlegroups.com
Hehe. Magic. The PROFILE_URL links back to your site, but it
contains a special query parameter. The Friend Connect library
automatically detects those query parameters and opens a Lightbox
window that points to the correct profile. As long as the PROFILE_URL
is pointing to the right page, it Just Works™.

-Bob

Resseguie

unread,
Nov 13, 2009, 5:01:33 PM11/13/09
to Google Friend Connect Developer Forum
As I suspected. What do you mean by "pointing to the right page"?


On Nov 13, 4:58 pm, Bob Aman <boba...@google.com> wrote:
> > When you click on a profile picture in the members gadget and on
> > several of the sample sites (likehttp://www.ossamples.com/api/), a

Bob Aman

unread,
Nov 13, 2009, 5:07:48 PM11/13/09
to google-friend-co...@googlegroups.com
> As I suspected. What do you mean by "pointing to the right page"?

The PROFILE_URL combines your Home URL with the query parameters. So
if you have the GFC Home URL pointing someplace strange, you might get
taken somewhere unexpected.

-Bob

Resseguie

unread,
Nov 13, 2009, 5:16:43 PM11/13/09
to Google Friend Connect Developer Forum
Right. Perhaps I'm missing something obvious then.

Are you referring to the value set using setParentUrl() ? I just have
that still set to "/" as suggested when I generated a gadget.

I was going to change that to something like "/profile.php" and then
read in the passed ID to generate a site-specific profile page
(including some data from GFC and also site-specific stuff).

But I still don't understand how to get that lightbox magic to work,
and my plan above seems it might even conflict with that.

Resseguie

unread,
Nov 13, 2009, 5:23:19 PM11/13/09
to Google Friend Connect Developer Forum
Wait, the page at "/" doesn't have the API on it. So if I point it to
a page with the JS API, then it would just work perhaps?

Off to try that...

Bob Aman

unread,
Nov 13, 2009, 5:30:11 PM11/13/09
to google-friend-co...@googlegroups.com
> Are you referring to the value set using setParentUrl() ? I just have
> that still set to "/" as suggested when I generated a gadget.

No, I'm referring to the Home URL in the Friend Connect admin settings.

> I was going to change that to something like "/profile.php" and then
> read in the passed ID to generate a site-specific profile page
> (including some data from GFC and also site-specific stuff).

No, that's not what setParentUrl() is for. Generally leave this set
to the top-most directory for your site, usually "/". This function
call may be necessary at some later point in time (and indeed, right
now, if you omit it, almost everything should still work fine), but
for now, just ignore it and leave the value the same.

-Bob

Resseguie

unread,
Nov 13, 2009, 5:37:46 PM11/13/09
to Google Friend Connect Developer Forum
Okay, so it's not the parent URL that affects this. It's the "Home
URL" under settings on the GFC page. I was trying to mess with parent
URL. (So what does that do then?)

I had the Home URL pointing to our main web home, not the URL of the
application that's using GFC. (The web home has introduction, blog,
etc but doesn't use GFC.)

Once I pointed it to the URL of the actual application, the lightbox
works automagically as you described.

But does that mean that if you have multiple pages within an
application that it will always take the user back to the "home" page
when they click a profile thumbnail liked to PROFILE_URL? What if you
want them to stay on the same page but just have the lightbox? Is that
not possible? Is there any way to access the "magic" another way?

And my previous idea of having the home URL (I originally thought
parent url) point to a profile.php page to generate a site-specific
profile won't work. It would open up a lightbox on top of the site
specific profile. I just need to grab the user's ID and manually
create a link to the profile.php page. That's fine, not a big deal.

David

Resseguie

unread,
Nov 13, 2009, 5:39:50 PM11/13/09
to Google Friend Connect Developer Forum
Our messages passed over the "tubes" so you can ignore my questions
about use of parent URL. thanks for the clarification.

Still curious about whether or not you have to refresh to the home URL
every time someone accesses the PROFILE_URL.

Bob Aman

unread,
Nov 13, 2009, 5:52:37 PM11/13/09
to google-friend-co...@googlegroups.com
> But does that mean that if you have multiple pages within an
> application that it will always take the user back to the "home" page
> when they click a profile thumbnail liked to PROFILE_URL? What if you
> want them to stay on the same page but just have the lightbox? Is that
> not possible? Is there any way to access the "magic" another way?

Yes, that's exactly what happens, and therein lies the rub. I'm
trying to get this issue resolved, but right now the only work around
is to either use server-side redirects to send the person to the
desired page from the home URL (ick, massive hack, please don't do
this) or to manually rip off the absolute section of the profile URL.
The browser will then be responsible for making the correct URL
resolution.

So for instance, if your home URL is http://example.com/ then the
profile URL will be http://example.com/?someid=1234 — you want the
final result to be http://example.com/current/page/?someid=1234 so you
replace the value of you_home_url (in this case,
"http://example.com/") with "", resulting in a URL of "?someid=1234".
The browser treats this as a relative URL, and sends the visitor to
"http://example.com/current/page/?someid=1234" as desired.

I know that's some serious work, and most of it has to happen in
JavaScript, but right now that's the only sane work-around.

> And my previous idea of having the home URL (I originally thought
> parent url) point to a profile.php page to generate a site-specific
> profile won't work. It would open up a lightbox on top of the site
> specific profile. I just need to grab the user's ID and manually
> create a link to the profile.php page. That's fine, not a big deal.

Yes, that's correct. In this case, it would be far, far less hacky to
intercept and redirect these to your site-specific profile.

-Bob

Resseguie

unread,
Nov 13, 2009, 9:16:07 PM11/13/09
to Google Friend Connect Developer Forum
> So for instance, if your home URL ishttp://example.com/then the
> profile URL will behttp://example.com/?someid=1234— you want the
> final result to behttp://example.com/current/page/?someid=1234so you
> replace the value of you_home_url (in this case,
> "http://example.com/") with "", resulting in a URL of "?someid=1234".
> The browser treats this as a relative URL, and sends the visitor to
> "http://example.com/current/page/?someid=1234" as desired.
>
> I know that's some serious work, and most of it has to happen in
> JavaScript, but right now that's the only sane work-around.

That's actually not that bad and I'm doing most of this in JS already
anyway. I'll give it a try when I'm back at the office.

One suggestion, if I may, since it sounds like this is still something
you're working through... It would be really nice to avoid the page
refresh to get the lightbox with profile information. The rest of our
site is AJAX based so it feels somewhat clumsy to refresh, especially
for what just appears like a dialog box to the end user. It also
requires the site developer to be more careful about maintaining state
when the page refreshes--and it has to be a server-side solution using
sessions (or maybe cookies) since you have limited control over what
the URL looks like.

Just had an idea I might try as a workaround. Could you make the "home
url" be just a blank page and then set it to open in a new window
(target="_blank" or similar). Then if you could detect when the
lightbox is closed, you could just close the window and you're back on
the original page w/o refresh. I'll have to think through the details
of how that might work.

Thanks for your help. Have a good weekend. I'll probably be mostly
quiet until Monday. Unless I can't sleep because I'm problem solving
in my head, which happens from time to time. :)

David

Bob Aman

unread,
Nov 13, 2009, 9:24:54 PM11/13/09
to google-friend-co...@googlegroups.com
> One suggestion, if I may, since it sounds like this is still something
> you're working through... It would be really nice to avoid the page
> refresh to get the lightbox with profile information.

You can avoid this by using the undocumented
google.friendconnect.showMemberProfile(gfcID) method. Note that using
undocumented methods aren't really supported, may break at any moment,
and may or may not work in all situations (like Canvas mode vs
Lightbox mode). Use at your own risk... but it does exactly what you
want. :-)

-Bob

boethius

unread,
Nov 14, 2009, 12:24:56 PM11/14/09
to Google Friend Connect Developer Forum
It looks quite good if you set your home page URL as an splash page,
the profile pop up then appears to be mounted upon a well designed
background.
> > -Bob- Hide quoted text -
>
> - Show quoted text -

Bob Aman

unread,
Nov 14, 2009, 2:36:37 PM11/14/09
to google-friend-co...@googlegroups.com
> It looks quite good if you set your home page URL as an splash page,
> the profile pop up then appears to be mounted upon a well designed
> background.

I don't think we wrote it that way with that in mind, but hey, if you
like it, glad to hear it!

-Bob

Resseguie

unread,
Nov 18, 2009, 12:53:31 PM11/18/09
to Google Friend Connect Developer Forum
I just tried the undocumented google.friendconnect.showMemberProfile
(gfcID) method.

It opens the dialog box, shows site name and signing gadget (ie my
mug, invite, settings, etc), but the rest of the dialog is blank and
doesn't show the user's profile info.

I just pass in value from friend.getId() right?

Resseguie

unread,
Nov 18, 2009, 12:56:44 PM11/18/09
to Google Friend Connect Developer Forum
I just noticed that the status bar is saying "Waiting for www.google.com"
after the blank dialog opens.

Bob Aman

unread,
Nov 18, 2009, 2:06:43 PM11/18/09
to google-friend-co...@googlegroups.com
> I just pass in value from friend.getId() right?

Any GFC ID should work, yes. The http://ossamples.com/interests/ page
uses this technique on the 12 member pictures shown at the bottom.

> I just noticed that the status bar is saying "Waiting for www.google.com"
> after the blank dialog opens.

Did you verify that the ID you passed to the function was legitimate?

-Bob

Resseguie

unread,
Nov 20, 2009, 5:08:59 PM11/20/09
to Google Friend Connect Developer Forum
I went back to look at this issue again and now I'm seeing an error in
Firebug:

gfc_c is null
http://www.google.com/friendconnect/script/mod_gadget_members__en_US.js?v=0.488.5
Line 44

I verified that the ID is valid.

Resseguie

unread,
Nov 20, 2009, 7:48:53 PM11/20/09
to Google Friend Connect Developer Forum
I also implemented the splash page version and it does work pretty
good, though not as clean as the undocumented call (if I can get it to
work).

Only problem with the splash page is closing it. Is there a way for me
to detect when the lightbox has been closed so I can close the splash
window too?

David

On Nov 20, 5:08 pm, Resseguie <da...@resseguie.com> wrote:
> I went back to look at this issue again and now I'm seeing an error in
> Firebug:
>
> gfc_c is nullhttp://www.google.com/friendconnect/script/mod_gadget_members__en_US....

Resseguie

unread,
Nov 20, 2009, 7:55:21 PM11/20/09
to Google Friend Connect Developer Forum
Of course I can just use jQuery to handle it:

$('.modal-dialog-title-close').click(function(){
window.close();
});

making sure to wait until the lightbox has been rendered to add the
click handler...

David

Bob Aman

unread,
Nov 21, 2009, 1:38:49 AM11/21/09
to google-friend-co...@googlegroups.com
> Of course I can just use jQuery to handle it:
>
>      $('.modal-dialog-title-close').click(function(){
>         window.close();
>      });
>
> making sure to wait until the lightbox has been rendered to add the
> click handler...

A little hacky... not sure that's the best solution, especially if we
ever get around to binding a keyboard shortcut like Esc to close it
(which we probably should). Unfortunately, I don't have a good answer
for you, but if you're happy with that solution...

-Bob

Bob Aman

unread,
Nov 21, 2009, 1:40:06 AM11/21/09
to google-friend-co...@googlegroups.com
> I went back to look at this issue again and now I'm seeing an error in
> Firebug:
>
> gfc_c is null
> http://www.google.com/friendconnect/script/mod_gadget_members__en_US.js?v=0.488.5
> Line 44
>
> I verified that the ID is valid.

Got a page I can look at? (That's pretty much my answer for
everything, I know...)

-Bob

Resseguie

unread,
Nov 24, 2009, 11:35:39 AM11/24/09
to Google Friend Connect Developer Forum
I figured out what I was doing wrong while working up a simple example
to reproduce. It worked fine on my sample page, so I dug in to figure
out what I was screwing up.

I had a link like this:
<a href="javascript:google.friendconnect.showMemberProfile('+id
+')">View Google Profile</a>

instead of like this:
<a href="javascript:google.friendconnect.showMemberProfile(\''+id
+'\')">View Google Profile</a>

Note that I don't have escaped single quote characters around the ID
in the first link above. It looked correct at a glance and didn't
complain until clicked so I didn't notice it before.

Sorry for the wild goose chase.

I was interested to find out that if you just leave out the ID, it
opens a nice members dialog. That may also be handy.

David


On Nov 21, 1:40 am, Bob Aman <boba...@google.com> wrote:
> > I went back to look at this issue again and now I'm seeing an error in
> > Firebug:
>
> > gfc_c is null
> >http://www.google.com/friendconnect/script/mod_gadget_members__en_US....

Bob Aman

unread,
Nov 24, 2009, 12:45:59 PM11/24/09
to google-friend-co...@googlegroups.com
> I was interested to find out that if you just leave out the ID, it
> opens a nice members dialog. That may also be handy.

Interesting. I didn't know that.

-Bob
Reply all
Reply to author
Forward
0 new messages