Strange characters in URL #_=_ PHP does not show

86 views
Skip to first unread message

Jimboidaho

unread,
Mar 31, 2012, 12:34:11 PM3/31/12
to professi...@googlegroups.com
I have been integrating Facebook to authenticate my app.  I have all working well except for some strange reason, when FB redirects to my URL it adds #_=_ at the end of my URL.  I first thought I could fix this in PHP and redirect but the characters do not show up in any of the $_SERVER elements.  I ended up having to use javascript to fix the problem.  Just wondering why I couldn't do it in PHP?

Thanks.

Robert Gonzalez

unread,
Mar 31, 2012, 12:45:17 PM3/31/12
to professi...@googlegroups.com
Because the server doesn't see the anchor or anything beyond it. The anchor is for the client, as is demonstrated by the actions taken on the client when clicking a link that points to an anchor. There is no post back because the request is handled in the client.

Make sense?

A simple test for this would be to create a PHP script (called request.php for example) with this code in it:
<?php
var_dump($_SERVER['REQUEST_URI']);

Then hit that page on your server from a browser by going to http://yourserver/request.php?test=this#anchor

You'll see that it picks up everything up to the anchor.

On Sat, Mar 31, 2012 at 9:34 AM, Jimboidaho <jimbo...@gmail.com> wrote:
I have been integrating Facebook to authenticate my app.  I have all working well except for some strange reason, when FB redirects to my URL it adds #_=_ at the end of my URL.  I first thought I could fix this in PHP and redirect but the characters do not show up in any of the $_SERVER elements.  I ended up having to use javascript to fix the problem.  Just wondering why I couldn't do it in PHP?

Thanks.

--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
 
For information or project assistance please visit :
http://www.360psg.com
 
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP



--

Robert Gonzalez
   

Jimboidaho

unread,
Mar 31, 2012, 1:03:07 PM3/31/12
to professi...@googlegroups.com
Thanks Robert.  Learned something new.  Not sure why Facebook is doing that.  I am using Jquery Mobile and the anchor broke the page so I ended up with a blank page.  This fixed the problem.

var curl = window.location.toString();
if (curl.indexOf('#_=_') > 0 ) {
    var newval = curl.replace(/\#\_\=\_/,'');
    window.location = newval;

}

On Saturday, March 31, 2012 10:45:17 AM UTC-6, Robert Gonzalez wrote:
Because the server doesn't see the anchor or anything beyond it. The anchor is for the client, as is demonstrated by the actions taken on the client when clicking a link that points to an anchor. There is no post back because the request is handled in the client.

Make sense?

A simple test for this would be to create a PHP script (called request.php for example) with this code in it:
<?php
var_dump($_SERVER['REQUEST_URI']);

Then hit that page on your server from a browser by going to http://yourserver/request.php?test=this#anchor

You'll see that it picks up everything up to the anchor.
On Sat, Mar 31, 2012 at 9:34 AM, Jimboidaho <jimbo...@gmail.com> wrote:
I have been integrating Facebook to authenticate my app.  I have all working well except for some strange reason, when FB redirects to my URL it adds #_=_ at the end of my URL.  I first thought I could fix this in PHP and redirect but the characters do not show up in any of the $_SERVER elements.  I ended up having to use javascript to fix the problem.  Just wondering why I couldn't do it in PHP?

Thanks.

--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
 
For information or project assistance please visit :
http://www.360psg.com
 
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professional-PHP@googlegroups.com
To unsubscribe from this group, send email to Professional-PHP-unsubscribe@googlegroups.com

For more options, visit this group at http://groups.google.com/group/Professional-PHP

Jimboidaho

unread,
Mar 31, 2012, 1:05:14 PM3/31/12
to professi...@googlegroups.com
I should have said that this javascript fixed the problem.

Robert Gonzalez

unread,
Mar 31, 2012, 1:45:14 PM3/31/12
to professi...@googlegroups.com
You might want to consider stripping the anchor and everything after it from the URL. Only suggesting that because if Facebook changes something, like the anchor value, your page will break again. It'd be best to just get rid of it entirely, not based on value but by position or even regular expression. 

Jim Blackburn

unread,
Mar 31, 2012, 6:33:19 PM3/31/12
to professi...@googlegroups.com
Thanks. I will do that.
Sent from my ASUS Eee Pad
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com

vishal bhandare

unread,
Apr 2, 2012, 2:53:43 PM4/2/12
to professi...@googlegroups.com
Hi,

Following blog might help

https://developers.facebook.com/blog/post/552/

It says
we started adding a fragment #_=_ to the redirect_uri when this field is left blank


Regards,
Vishal
--


Reply all
Reply to author
Forward
0 new messages