× Joomla Facebook Connect support forum

Topic-icon Handling App Requests inside Canvas

Active Subscriptions:

None
14 years 8 months ago #13521 by Ivan
Alex,

Where/how could we handle app requests when we are inside canvas? When we have an app request facebook takes us within the canvas and proves us with a request id eg. apps.facebook.com/myappname/?request_ids=1234324324

Using the php SDK we could delete requests in this way:

$reqId = $_GET['request_ids']; // Get the id of the current request
$requests = $facebook->api('/me/apprequests/?request_ids='.$reqId);  //Get the request. Not sure if this is correct for specific request
$itemData = $requests[data][0][data];  //Get the data that was originally sent in the request

//Some code here to do whatever with the data

$delete_url = "https://graph.facebook.com/".$reqId."?access_token=".$token."&method=delete";

    $result = file_get_contents($delete_url);  //Delete the request so there is only one there next time.

Ive tried to use the code above in the login module .default.php but I cant seem to get any request id in $reqId = $_GET; even though im seeing the request_id var in the URL /address bar
The topic has been locked.
Support Specialist
14 years 8 months ago #13533 by alzander
WIth Joomla, you should be using the JRequest::getInt('request_ids') function, as that's the 'Joomla-way' to do it. However, if it's not showing up in the GET variable, I'm not sure that it would show up any better using JRequest. There's nothing I can think of that should be removing that parameter from the query string, but you will obviously need to find the cause.

We haven't dealt with app requests a lot, so I really don't know the code you'd need, or the solutions to problems you may run into. We'll help where we can, but don't think I'm going to have a lot of answers.

Alex
The topic has been locked.
Active Subscriptions:

None
14 years 8 months ago #13684 by Ivan
I have had no luck getting the request_ids variable when inside the canvas. if i do a $reqId = $myabsoluteurl=JURI::base(); i would get

subdomain.mysite.com and wouldn't get the url within that canvas that FB redirects me to....

is there any setting that facebook has enabled. in previous versions i could post a link to my wall that would return to the canvas url and i could get the variable at the top. previous 3.x
The topic has been locked.
Support Specialist
14 years 8 months ago #13716 by alzander
Ivan,
I think I misunderstood previously.. but hopefully have a solution. If you're seeing the request_id variable in the Facebook URL, you likely won't be able to see it directly in the Joomla site, since it's loaded in an iFrame. I'm not sure what information from the 'original' query string is passed along to the frame, but you can try the following to get the original Facebook query string:
$qs = $_SERVER['HTTP_REFERER'];
$request_ids = $qs['request_ids'];
Hopefully, that will help you out, but if not, let me know if at least what I'm saying above is what you're seeing with the address bar.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 8 months ago #13757 by Ivan
Hi ALex,
In $qs i do get the entire apps.facebook.com url however the 3nd line $request_ids = $qs; gives me an unknown string 'h'
The topic has been locked.
Support Specialist
14 years 8 months ago #13801 by alzander
Does the $qs string contain the request_ids, and it's just causing an issue when you try to access that value in the array, or can you not even see the request_ids in the main URL?

I was incorrect above. The HTTP_REFERER value, I think, will just return a string, not an array of each key like the $_GET or $_POST values. You'd need to parse that yourself, which should be pretty easy by just doing:
$uri =& JURI::getInstance($qs);
$request_ids = $uri->get('request_ids');

Hopefully that gets you fixed up!
Alex
The topic has been locked.