Facebook Page Tab does not forward - php

I implemented a Facebook Like Status Request on my Page Tab but if I want to click on the "next"-Link (to see index.php?action=step2) it loads the page that pops up if Like Status = Not Like. If I want to link to http://www.google.de the Page Tab doesn't load any page at all. What am I doing wrong?

I'm assuming you're detecting if the user likes your page or not via the signed_request parameter POSTed to your app's page
If so, any links the user clicks inside the iFrame containing your app will be GET requests to a different URL which will not contain the signed request with the like data - you'll need to use your own mechanism (e.g. cookies, url parameters) to pass the 'like' information from the first to second page of your app

Related

Server-Side redirection after a fetch request

Let's say, we work on a project in a web tool and after some period of time the app wants to save the project as backup before the session expire.
For the saving, we use fetch method(it could be AJAX, Axios etc) and we post a request to a controller function, in which we save the project, clear the session and want to redirect to the home page. I've tried this scenario with Laravel but when the time for redirection come, the session data is cleared but the server doesn't redirect to the home page.
Is it because of the fact that the fetch and the other types of asynchronous functions wait always for response?
A redirect means "What you asked for can be found here" not "Load this URL in the main browser window".
If the browser was asking for a URL with the intention of showing it in the main browser window (e.g. a link was clicked) then it would follow the redirect and show it in the main browser window.
If the browser was planning to do something else (e.g. render an <img>) then it would follow the redirect, get the image at the new URL, and render that in the <img>'s spot.
Ditto Ajax. You are making a request with Ajax, so the browser follows the redirect and gives the resource at the new URL to JavaScript to process.
If you want to make a POST request which loads a new document in the main browser window: Submit a form and don't use Ajax.

Need tp find Request source URL in PHP

I want to determine the website from which the request to the particular website has been called. For Example..I have a website www.ex.com. Now this website link has been there on three websites www.a.com, www.b.com, and www.c.com. Suppose one user has clicked the link from www.a.com to go to www.ex.com. Now I want to determine that the request has come from the www.a.com and then the page in www.ex.com will be displayed accordingly. Similarly if the user has clicked the www.ex.com link from www.b.com then the page will be displayed accordingly.
So how can I determine this request source, means from which website www.ex.com has been called? It is good if you will explain this using code in PHP.
Thanks
Look here for HTTP_HOST and HTTP_REFERER.
Since both global variables are populated from HTTP headers, look also here for Host and Referer.
That's how you use them:
$host = $_SERVER['HTTP_HOST'];
$referer = $_SERVER['HTTP_REFERER'];
The 1st is the original host name (like 'www.a.com') referring to your page. The 2nd is the full URL (like https://www.a.com/some/path/to/some.html).
Then, based on some conditional logic, you may return to your users appropriate HTML.
There are two different websites.
Say from a.com, you click on ex.com
So, for the link in a.com, add some parameter:
Click Here
Now, your from parameter will be
1) a.com
2) b.com
3) c.com
If none of the above, then its clicked from ex.com itself.
You can also add some encryption for this link to add security.
You can use this
$_SERVER['HTTP_REFERER']
for referral url

How can I get Infusionsoft's Cookie Info from this URL

Infusionsoft provides the following script / method of obtaining an affiliate ID. Now, I want to call that URL programmatically and just get back the affiliate ID - I don't want to redirect or go anywhere else, I just want the affiliate ID to use in a following query. I know there has to be a way to do this, but I have no idea what it might be...
--
Here is an example of the modified redirect link URL. You will need to change highlighted sections to enter your Infusionsoft application name and the URL of your destination website.
https://appName.infusionsoft.com/aff.html?to=http://www.example.com
If the prospect clicking on this link has a referral cookie stored on their browser, the partner will land on a page with a URL something like this:
http://www.example.com?affiliate=1234
The destination URL matches the one at the end of the redirect link and the referring partner's ID is part of the URL. If no cookie is found, the referral partner ID number is set to zero.
I think I've looked into doing this before. It seems to me that if you created a page to redirect to, for example, http://www.example.com/affiliateId.php, and on that page you echoed nothing but the affiliate ID, like so:
<?php echo $_GET['affiliate']; ?>
You could simply cURL that page and pull in the response. The problem here is that when you cURL the page, it's actually your server going to the page, and not the user's computer, so it always returns 0.
So, somehow, you need to get the user's computer to navigate to the page, perhaps through the use of an iframe or an ajax call and then pull the information after it's been rendered using a client side script.

Can't get proper signed_request info after redirect within FB Page tab App

Initially upon landing on the app, $facebook->getSignedRequest(); gives me the proper info I'm looking for, like info about the current page etc. But then after clicking through links within the app the returned array from $facebook->getSignedRequest() is different. It contains [code] but nothing about if the page is liked etc
How can I resolve this? Is it rather best practice to change pages within the app via parent.location.href ?
Redirects within your app will not receive the signed_request parameter. You'll have to manage saving that data yourself (in the session variable for example).

Determine if request came through a Facebook page tab

If the user visits foobar.com through a Facebook page tab I'd like to show them specific data.
However, if the user goes directly to foobar.com I'd like to show something different.
I've not been able to come up with one good method to do so.
Check out signed_request which is sent to each page loaded in a Facebook tab.
if (isset($signed_request['page'])) {
// I'm in a tab
}

Categories