Hey,
First off, I just want to apologise for my lack of understanding in PHP and Javascript. I have a small amount of experience with the latter and, until now, none at all with the former. I can imagine that a lot of people here would prefer it if people went out to learn the language a little first before asking for help on a forum such as this, and under other circumstances I’d do exactly that, but unfortunately since I have some programming experience (in java) my boss has given me this task and the deadline is relatively short. Unfortunately, this leaves without the luxury of learning what I’m doing before jumping in.
Anyway, my problem.
I’m trying to get an app within facebook to grab a city name from the page URL and use it to load the correct gallery for the city page it was accessed from.
I’m trying to do it by doing most of it in php, as I was given a basic php framework to start with, but have a little bit of javascript that grabs what I need from the page URL since php isn’t capable of getting the correct url (it’s loaded within an iframe on facebook and, as such, doesn’t return the right URL when I use $_SERVER[“REQUEST_URI”] and the like). Naturally, I need to get this variable back to the php so I send it across in the URL and reload the page.
Any help at all would be greatly appreciated. Everything in the php seems to be working, but it’s not reading the javascript at all (I don’t get the “in javascript” message in the output). Here’s the code I have:
"); if(isset($_GET['flag'])) { $city = $_GET['city']; echo "Page was recalled and php result is ".$city; } $app_id = "235822949779607"; $app_secret = "b00312ad4017b5c01c40d42af35efa24"; $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true )); $signed_request = $facebook->getSignedRequest(); print("Facebook stuff done
"); ?> <?php print("back in php
"); function parsePageSignedRequest() { if (isset($_REQUEST['signed_request'])) { $encoded_sig = null; $payload = null; list($encoded_sig, $payload) = explode('.', $_REQUEST ['signed_request'], 2); $sig = base64_decode(strtr($encoded_sig, '-_', '+/')); $data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true)); return $data; } return false; } if($signed_request = parsePageSignedRequest()) { if($signed_request->page->liked) { include(city+"gallery.php"); } else { echo "
Done?