# AIM and PHP: maybe I'll have better luck here...



## mussavcom (Mar 29, 2004)

None of the other forums I post on could help me with this, but I'll give it a try here.

You may be familiar with SubProfile. It's a free software & server where users can create "subprofiles," which have subpages the user makes, like jokes, etc., guestbooks, and visitor logs, to name a few features. You place a link to your SubProfile site in your AIM profile. The link is set up so it opens in the Get Info window, and so it links to something like:

subprofile.com/v.php?userid=23236235235&nick=%n

AIM automatically replaces the %n with the person's AIM screen name, so the link would be like:

...&nick=myscreenname

I created a PHP page hosted on my server which I link to in my AIM profile. It has a visitor log much like SubProfile's,. Now, the %n thing works if the user's screenname is only one word--that is, no spaces. If his/her sn is something like "my screen name," however, the user will get an "error loading content" message when he/she click the link. SubProfile somehow found a way around this, because theirs works. Do any of you happen to know what I could do?

Thanks.


----------



## mussavcom (Mar 29, 2004)

P.S.: A lot of things didn't work for me so far... check out http://www.lunarforums.com/forum/viewtopic.php?t=9261&postdays=0&postorder=asc&start=0


----------



## Snake~eyes (Apr 18, 2002)

I understand what you're trying to do but not the error you're getting.


----------



## mussavcom (Mar 29, 2004)

If you click on a link in AIM that has a space, like

http://google.com/search?q=asdf fdsa

and set the target to _self so it opens in the Get Info window, it will load for half a second and then show:

Error Loading Content

Somehow SubProfile gets around this... I can't figure out how. Anything I try with a space doesn't work. People suggested encoding my URLS and stuff, but it doesn't even get my page, I don't think--it just bombs immediately.


----------



## Shadow2531 (Apr 30, 2001)

This is kind of repeating from that other forum..

You said aim uses %n as the screen name argument.

A space is encoded as %20

If a screen name = My Screen Name

then %n = My%20Screen%20Name

Perhaps the percent signs are confusing your php script although they should not if you are just grabbingthe variable.

Aim might use + instead of %20.

So if you have php file like

http://www.mysite.com/aim.php?nickname=%n and put it in the additional info for your profile and Bobby Joe45 gets your info and clicks on the link, then it would load

http://www.mysite.com/aim.php?nickname=Bobby Joe45

or possibly

Bobby+Joe45

So check your php script, to make sure it's grabbing the entire part. Create a screen name with spaces in it to test with.

How can you have a screen name with spaces though?

If you signup as bingo 123four , it will auto change it to bingo123four on registration.

I've never seen an aim screen name with a space in it.

You can format your screen name to add a space in it. (at least in opengaim), but the %s variable does not store the space.


----------



## mussavcom (Mar 29, 2004)

No, actually, the %n variable does display the space, too, which means it displays it in the URL. So there's no %20 and no +, just a space:

http://www.mysite.com/aim.php?nickname=Bobby Joe45

Now, from here, SubProfile and all the rest have done something, I don't know what, to prevent an error from occurring. I don't think it has anything to do with the PHP, although I could be mistaken, because it seems that any page with a space in it will not load in AIM.

Perhaps something in the Apache config that must be changed to change the URL before it gets to the script?

I seriously have no idea, this is very weird.


----------



## Shadow2531 (Apr 30, 2001)

Stepping aside for the aim part of it,

Just for kicks, what if you just pasted the following in your browser. (path to your php file of course)

http://www.mysite.com/aim.php?nickname=Bobby Joe45

or

http://www.mysite.com/aim.php?nickname=Bobby Joe45

Does it work then?


----------



## Shadow2531 (Apr 30, 2001)

are you just typing the URI in the more info box for your profile?

like just typing

http://www.mysite.com/aim.php?nickname=%s

or are you clicking on the *link* next to the smiley to create a new link.

You should be doing the latter.

It will ask you to input the URI and input the uri text.

If you do it like that, then spaces in the screen names should not be a problem.

See if you just type

http://www.mysite.com/aim.php?nickname=1 2

aim will make just

http://www.mysite.com/aim.php?nickname=1

the link and the space and 2 will be text.

Same thing will happen if %s was there and the %s got replaced by a 2 part name.

However, if you use the link function to create a new link, it should work.

so if %s = bob charley, bob charley (along with the first part of the uri) will be sent to your browser. Your browser will then encode boy charley to bob%20charley.

If it still doesn't work, then you can post the php part that grabs the nickname variable and we can see if that's O.K.

How do you get a 2 part screen name though?


----------



## mussavcom (Mar 29, 2004)

First, it's got nothing to do with my browser--like I said before, it opens the site in the AIM Get Info window like all the other profiles. So it doesn't encode it, it just makes it

http://abc.com/p.php?n=he llo

Second, yes, I do the link button thing to enter the address.

Third, I don't think it has anything to do with "the php part that grabs the nickname variable" because it doesn't even seem to load the PHP part, it will just display the default AIM error message, and I think that's because it can't go to a URL with a space in it. It doesn't matter that the space is in a variable.

Fourth, to make a space in your screenname, click My Aim, Edit Options, then Format Screen Name. Then, if you add a space (or more than one space), %n will be replaced with the username, including the space(s).


----------



## Shadow2531 (Apr 30, 2001)

I formatted my screen name to add a space. %n still took the space out.

I noticed there was a new version of aim, so I updated it and the %n kept the space.

So we are on the same speed there now.

Now if I GetInfo on somebody in my list to check out their profile, any links in the personal profile box I click on, will open in my default browser. How do you get them do open in aim? (You said it has nothing to do with my browser and it loads in aim)

All the link does is load in my default browser and my browser changes the space to %20 just like any good browser does.

If I right-click on the link in the personal profile and click "show hyperlink" it will show the URI with the space as a space and not %20.

So far I don't see anything wrong with Aim.


----------



## mussavcom (Mar 29, 2004)

Instead of making a link, I do what SubProfile makes its users do: copy this code and paste it into AIM:

Link

(You have to copy it from here and paste it into something like NotePad or even your browser's address bar; then copy it from there, and paste it into your profile. Otherwise, just copying it from here, I think, will display the code in your profile, and not make it a link.)


----------



## Shadow2531 (Apr 30, 2001)

ok, I see what you mean.

Now I'll see what I can figure out.

edit:

The problem is definitely with aim not converting or keeping the space as %20 when using target="_self" . It's not just a problem with the %n though.

Put these 2 URIs in the profile to test with.

Link

Link

The first one will work, but the second one won't.

Aim should convert the space between test and cases so that it can complete the URI. Aim is not capable of handling the space when using target="_self". If you use a regular link and click on it, it will work right, but that's not what you want to do.

However, there maybe another way of inputing the URI into the profile so that aim can handle it. I'll still be looking for a way.

For now, you should offer 2 links in your profile.

One with target="_self" and then a regular link that opens in the persons default browser.

So if the one doesn't work, they can use the regular link.

I personally would rather have it open in my browser anyways.

These things you know though.


----------



## mussavcom (Mar 29, 2004)

Thanks! If you run into anything else that doesn't make sense (other than the whole thing, of course ) let me know.


----------



## Shadow2531 (Apr 30, 2001)

I consider the problem to be a bug.

Formatting the screen name should not change the %n value.

Formatting the screen name doesn't actually change your screen name anyway. It's just for display purposes. (Well it's supposed to be anyway)

If you are joebob and format it as joe bob, people are still IMing you at joebob, it just shows up differently, but it really hasn't changed.

Now what they could do is keep %n as the nickname and have %f to show the formatted screen name, which could be the same as %n if the person didn't format their screen name.

Once aim is fixed for that, you can rely on %n to not contain spaces and you are all set. No sense in logging a person's formatted screen name anyway.

However, aim still needs to be fixed to handle spaces in your situation.

You could submit a report at the aim site.


----------



## mussavcom (Mar 29, 2004)

Thanks for taking the time to try to help me. As I've said before, SubProfile formats the link exactly the same way, so they've done something about it other than modifying the link, although I have no idea what. Is it possible they did something in their Apache config or elsewhere on the server that "helped" AIM get its request in?


----------



## Shadow2531 (Apr 30, 2001)

I did not check out subprofile or any of the other sites that do it, but I read about them.

Some of them might have you put a link into your profile that just points to a regular page. When reading about them, I saw no reference of of use target="self". They just use a regular LINK.

Then on that page, there might be special aim links that only do something if you are viewing the page through aim. Then those links, when clicked on, do the action and work properly.

I have no details as to what; was just browsing.

I know there are "add buddy" links etc. maybe there's an aim:screenname type link that works when you are viewing the page with aim.

Again, still not sure how subprofile does it.

It might be a server configuration thing, but it's hard to tell what aim is sending to the server. Maybe I can run aim through a proxy program and see what's going on.

edit:

ran aim through proxomitron.

Aim connects directly to the site linked when using target="_self" . It does not connect first to the aol server and then grab the site.

Other than that, proxomitron didn't give up too much info except aim id and aim's user agent string.

Are you sure subprofile's method works when using target="_self" ?

I don't see how their method will work when using target="_self" because of the "what I consider to be a bug" problem.

It may have worked in a different version of aim, but for the current one and the the previous version I had, I don't think it will work by using subprofile.com/v.php?userid=23236235235&nick=%n and target="_self". (when their's a space in the name)

If you use just a regular link and have it open in the person's browser, everything works perfect.

If there is a way to do it in the aim window, then I would search for ways of ecasing the %n so that the space in a screen name get's encoded to %20, so aim doesn't have a fit.

It would be cool if you could do something like userid=23236235235&nick=[%n] or something to that effect, so that aim encodes the space as %20.

I would search for something like that.

I'm not saying your crazy, I'm just saying I don't see how it could work with with the way aim is now.

I would also goto aim.com, use the "report a problem" link and tell them what's up and send them the link to this post, so they can say "yeh this is a bug" or "no sillies, this is how you do it"


----------



## pickleman (May 14, 2004)

I just saw this thread while browsing google, and fifured I could offer you some insight. I have had this problem before, but I'm not totally sure how to fix it.

Just as a note, AIM does not properly encode a link, so the request made to the page, trys to pass the second part of your screen name to the server as part of the protocol string, so the server returns a 401 error (I think, its a bad request error) to AIM. So you have to send back an OK heder. The rest of the users screen name will be in $_SERVER['PROTOCOL_STRING'] (or something like that, I forget the exact name). One problem I have had is the server may just stop before the PHP script gets the request, so you have to make your server catch it, and then redo the request using the right protocol string (I think this can be achieved on apache using mod_rewrite).

I have never gotten this to work right, but this is how subprofile does it I beleive. I have never found a good working answer for this problem, but if you figure one out from the info I gave you, please let me know.


----------

