have created a Facebook App,As we know Facebook app have 2 URLs. Page Tab URL and Application URL.In my code if I redirect user to Page Tab URL it gives me FacebookGraphMethod Exception.May be I need to redirect with additional parameters.Anyone who can help with this\
For Example
The Page Tab URL is abc.com/main.php
From main.php I navigate to xyz.php
Now I want to go back to main.php what should I do,I even tried window.location.href
Thanks
you first need to add your App to a page. Then, you can access it on this page by clicking he app icon (or to an URL like this: http://facebook.com/{{page_username}}/app_{{app_id}}).
You can get the page username using this method on FB API:
$profile = $facebook->api('/' . $PageInfo['page']['id'], 'GET');
$page_username = $profile['username'];
To add the app to a page, you can use the add page tab dialog: https://developers.facebook.com/docs/reference/dialogs/add_to_page/
Use top.location.href to redirect to page tab.
<?php
echo "<script type='text/javascript'>top.location.href='".$fbpagetaburl."';</script>";
exit;
?>
Related
I'm building a plugin, but somehow when I post a form and redirect back to the page, the page is empty. Content returns after a page reload.
I use the following after the (successful) form submit.
wp_redirect(get_permalink());
exit();
I don't seem to get any errors (I do have WP_DEBUG on).
There can be cache in your browser or web server. You can try generate unique link for reload. For example add to url parameter.
$url = add_query_arg("unique", time(), get_permalink());
wp_redirect($url);
exit();
Iam just using an iframe for login and register.
and i need to reload the page when the message appears that he successfully registered/logged-in.
for example the iframe would be
when he click login in the iframe it reload other page called "login_success" this page send message"successfully logged in".
Now is the proplem i need the browser reload the page so that the session work in the page that loads the Iframe.
Thanks for responding.
You can use following script.
window.parent.location.reload();
Here it is
document.getElementById('ifarme_id').contentWindow.location.reload();
If it is in same domain you can try below
var myframe = document.getElementById('Ifrme_id');
myframe.src = myframe.src;
I have created a PHP password protected site with log-in page. I am using the following link for logging out.
<a href="admin.php?action=logout"?>Log out</a>
The problem is it redirects back to the index.php, but instead of showing my URL as EXAMPLE.com it shows my URL as EXAMPLE.com/index.php, which is undesirable. How can I accomplish a log-out and go back to the clean, desired url.
After logout redirect using the following command:
header("Location:http://www.example.com/login.php");
You can also do it by javascript in client side by using:
window.location='http://example.com/login.php'
In logout page you just add this redirect at the end of code
header("Location:http://www.example.com/");
This will redirect to the same index page with url example.com, but not show /index in url
Don't add
header("Location:http://www.example.com/index");
It will show example.com/index in url
I'm working on a jquery mobile web app and do a sessioncheck with php on pages I need the user to be logged-in. If not, the user will be redirected to the login.php?r=L29yZGVyLnBocD9kZWFsX2lkPTEwMDM2MjM= (base64_encode($_SERVER['REQUEST_URI']) to login. After the login he has to be redirected to the page he actually requested.
Unfortunately JQM doesn't update the URL, so i can't grab the GET parameter ?r=.... as it is not there. Just a page reload (F5) updates the url.
Here the sessioncheck code which does the redirect if user is not logged-in:
if(!isset($_SESSION["member"]) || (isset($_SESSION["member"]) && (int)$_SESSION["member"]["member_id"]==0)){
unset($_SESSION["member"]);
Header("Location: " . SITE_ROOT . "/login.php?r=".base64_encode($_SERVER['REQUEST_URI']));
exit;
}
What do you guys suggest to tell jQuery mobile that the target has changed.
Of course my redirect happens before the DOCTYPE tag
Cheers
Did you specify a data-url attribute into the page div?
<div data-role="page" data-url="/login" id="login-page">
How can I redirect a user to just added page after adding it through add.php?
let's say my url looks like: http://www.facebook.com/add.php?api_key=API_KEY&pages=1
After selecting a page from the select box and clicking 'Add MY_APP_NAME' user is redirected to the wall of the page instead of to freshly added MY_APP.
Notice
I know this type of questions lots of here but i have no found any solution that why i put this question here again.... helps are definitely appreciated
Tried
I tried myself like this using Javascript but seriously not success
<script>
if (window == top) {
top.location.href = 'https://apps.facebook.com/abc/' + document.location.href.replace(/https?:\/\/[^/]*\/?/, '');
}
function addToPage(page_id){
top.location.href = 'http://facebook.com/add.php?api_key=<?php echo C_APP_ID; ?>&pages&perms=publish_stream&page='+page_id;
}
</script>
See Image
https://www.facebook.com/dialog/pagetab?
app_id=APP_ID&
display=popup&
next=https://facebook.com
Using this alternative method you can specify the URL to be redirected to after interacting with the dialog to add an application to your page in the next parameter.
You could try adding that parameter to your request.
Other possible alternatives for the next parameter are -
redirect_url
redirect_uri
Both are used elsewhere when dealing with redirecting users - perhaps one of them will assist you as well...