how to access signed request on second page - php

My Two page facebook application contains
index.php
welcome.php
On index.php
$signed_request = $facebook->getSignedRequest();
works fine and i can get page id
but when i click on welcome page, and try to get page id,
$signed_request does not fetch page id.
[algorithm] => xxxx
[code] => xxxxx
[issued_at] => xxxxxx
[user_id] => xxxxxxx
got this but couldn't get page id

You only get $signed_requeston the first page. You should save it in a session if you want to use it on another page.

Related

How to pass link directly for my fb fan page using fb api

I have used link attribute under api() array and tried giving that link directly but somehow it is ot working showing 404 page not found error. Can we display iframe directly for fb fan page. Imean whichever iframe code we will send that should get displayed on fb page
below is the code i am using writing on fb page
$facebook->api(
"/".$this->data['pageid']."/tabs/app_".$this->data['selectmyid'],
"post",
array(
"access_token" => $pageAccessToken,
"custom_image_url" => "http://socialmobiapps.com/members/publishing-option/images/pagetab.png",
"link" => "http://linkconnect.me/published_deals/134/",
"custom_name" => $name1
)
);

How I can check that user has already liked page without user_likes permission

I also try get data from getSignedRequest() (PHP-SDK 3.4) but page data is empty in response:
Array
(
[algorithm] => HMAC-SHA256
[code] => AQC94XuRCkLCYkJkBU2j2JvR_H0dEesyyWE9IOnBorRExZyjDhRR1M5JnG5CiWLf12xuO0CiFzVva05D-L3NNuId-IbOg4VO8X-DENRlbj3CiSIzBn....
[issued_at] => 1408109031
[user_id] => 6660247934796
)
The 'liked' property will no longer be returned in the 'signed_request' object for Page Tab apps created after today.
https://developers.facebook.com/docs/apps/changelog
See v2.1 updates, Fangates are not possible anymore, and not allowed according to the platform policy of Facebook.

Adding Quesry string to Facebook fan page app

I have integrated a e-commerce site in my facebook fan page via page tab
https://www.facebook.com/Thesoftwareguy7/app_687345671301257
the problem it I want too append some custom url to it
https://www.facebook.com/Thesoftwareguy7/app_687345671301257?f=1
but when I parse the URL it gives me
Array ( [scheme] => https [host] => s-static.ak.facebook.com [path] => /platform/page_proxy/hv09mZVdEP8.js )
It worked perfectly in facebook apps when i append it in apps.facebook.com/687345671301257/
But it does not work in facebook fanpage custom tab.
Thanks for your time?
Did you have a look at the app_data field in the signed_request? The docs are here: https://developers.facebook.com/docs/appsonfacebook/pagetabs/#integrating
This would result in a Page Tab URL of https://www.facebook.com/Thesoftwareguy7/app_687345671301257?app_data=f%3D1
You then have to decode the app_data parameter to get the key/value.

Facebook PHP SDK: User ID on iframe page tab

I'm on my own page, I'm admin and I'm already "like" this peage, but this code:
require_once "api/facebook.php";
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => SECRET,
'cookie' => true
));
$signedrequest = $facebook->getSignedRequest();
$uid = $facebook->getUser();
gives me just this data:
### USER ID ###
0
### SIGNED REQUEST ###
Array
(
[algorithm] => HMAC-SHA256
[issued_at] => 1330166798
[page] => Array
(
[id] => 304887859549216
[liked] => 1
[admin] => 1
)
[user] => Array
(
[country] => us
[locale] => en_US
[age] => Array
(
[min] => 21
)
)
)
So, getUser() = 0 and user id from signed request - empty.
What im doing wrong?
By default the "user" is the page, this way you can display content from your app relevant to the page. To determine who the user is, you can go through the standard backend redirects you would go through as if the user came to your app with no session/expired token. But you need to remember what page your were on since Facebook only passes that information on initial iframe load.
For a better user experience, I would use the Facebook javascript SDK. You can check everything in javascript and determine who the user is without performing any redirects. You can even prompt for authorization without reloading the page. If the user already had authorized your app, they see no changes and get no prompts, but you now have a "session" with that user and know their ID in javascript.
https://developers.facebook.com/docs/reference/javascript/FB.login/
For getUser you need to log in in your application , show te login/permission dialog
Just to add to this you can't currently get everything in the javascript SDK. It doesn't give you any of the user or page (for page tab) data which PHP SDK does.

How to send custom value to facebook iframe

I m working on a facebook iframe application.
Facebook $_REQUEST response is as bellow:
Array
(
[signed_request] => some value
[PHPSESSID] => somevalue
[fbs_251034681599274] => somevalue
)
but i want one more parameter to its REQUEST so i want its response like bellow
Array
(
[fb] => some value
[signed_request] => some value
[PHPSESSID] => somevalue
[fbs_251034681599274] => somevalue
)
and that fb key will be dynamically.
Please help me how can i do it.
Best Regards,
Krishna Karki
If you want to identify users you need to use fb authorization (https://developers.facebook.com/docs/guides/web/#login) and then you can get some unique ids
OR you can generate that keys on your server (where that iframe source is)
if you just want to send some data with interaction on that iframe, do it same as you do it on a non-iframe-facebook-app page.

Categories