In This tutorial I will discuss how to remove hash symbol from facebook response. Normally when we are accessing graph Facebook api with “response_type=code” then we will get response like “http://abc.com/index.php?code=XXXXXX”.
Its readable format when we will parse URL in PHP with help of GET method, if we will access graph Facebook api with “response_type=Token” then we will get response like “http://abc.com/index.php#access_token=XXXXXX”.
If the URL has # tag then PHP does not have any method to get Query string variable access_token from Response URL.
To Solve this problem we will use Java Script technique.
Step 1:First we will get store Response URL in variable
var hashTag = window.location.href;
step 2: replace ‘#’ tag with ‘?’
var target = hashTag.replace(‘#’, ‘?’);
Step 3: Get index of ‘#’ tag
var hashIndex = window.location.hash.indexOf(“#”);
Step 4: Check its loaded when the # tag exist.
if(hashIndex != -1) {
window.location=target;
}
Full Code