How to send custom value to facebook iframe - php

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.

Related

How to get user's profile picture on Facebook

I'm a bit new to using the Facebook API and I'm currently trying to query the API for the user's profile picture. I am using this access-token return to get the user information when he/she logs in:
//Next get the user id of the current user, which is unique and will be used in the database
$response = file_get_contents("https://graph.facebook.com/me?fields=id,name,picture&access_token=$accessToken");
$data = json_decode($response);
print_r($data);
This print_r outputs:
stdClass Object ( [
id] => 0000000000000000
[name] => Username
[picture] => stdClass Object (
[data] => stdClass Object (
[is_silhouette] => [url] => valid_url )
)
)
However, the picture is low-resolution and also 50x50. How can I get a higher quality image and a higher dimension? I couldn't find any information in the API. I read the API (which added to my confusion), and it first asked me to add a redirect=false in my query (it was using an HTTP GET method)
I can specify it correctly in the http_get method
Fetch image based on Facebook id of user and you can get every size of image like below example :
Large : https://graph.facebook.com/{facebookId}/picture?type=large
You can change type based on your requirement here is the some type normal,small,square.
You can also use custom width and height for get any size profile picture by link http://graph.facebook.com/{facebook-user-id}/picture?width=1000&height=1000
and for type parameter you can use {small, normal, album, large, square}

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.

How to retrieve a specific discussion from linkedin group using PHP

How can I retrieve a specific post/discussion from a open group through LinkedIn API using PHP.
I was trying with the following API request as shown in here http://developer.linkedin.com/documents/groups-api#post :
https://api.linkedin.com/v1/posts/5835685921059532803:(id,type,category,creator,title,summary,creation-timestamp,relation-to-viewer:(is-following,is-liked,available-actions),likes,comments,attachment,site-group-post-url)
But this returns the following error:
Array
(
[status_code] => 400
[data] => stdClass Object
(
[errorCode] => 0
[message] => Invalid Post.id String {5835685921059532803}
[requestId] => XW2XMPBNKY
[status] => 400
[timestamp] => 1391441328953
)
)
Now, what's the error I have made with this request? What should I do to get a specific discussion?
Thanks.
I just solved the problem. The problem was while making the request. The discussion id (5835685921059532803) I was sending with URL was in wrong format. It should be like: g-GROUP_ID-S-DISCUSSION/POST_ID, for example: g-24405-S-5835685921059532803.
So the URL should be:
https://api.linkedin.com/v1/posts/g-24405-S-5835685921059532803:(id,type,category,creator,title,summary,creation-timestamp,relation-to-viewer:(is-following,is-liked,available-actions),likes,comments,attachment,site-group-post-url)
Hope this would save someone's valuable time.
You need An Api key and Secret key,to get an AUTHORIZATION_CODE,using that AUTHORIZATION_CODE,you will get an Access Token,and with that Access Token if you hit the url,then you will get the proper data,
details http://developer.linkedin.com/documents/authentication

How to get youtube download link from this array

I have a PHP script that returns the youtube's url_encoded_fmt_stream_map into arrays
this is an example of one of those arrays
Array
(
[quality] => hd720
[itag] => 45
[url] => http://r7---sn-25ge7n7l.c.youtube.com/videoplayback?source=youtube&expire=1377205488&cp=U0hWTFJLU19NUkNONl9KRVdFOlFROHcyQXZRVzMw&sver=3&mt=1377182899&itag=45&id=f3a24c732e4ea990&upn=aBSr1FoD9WM&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=919112%2C919363%2C914074%2C916624%2C909546%2C906397%2C929117%2C929121%2C929906%2C929907%2C929922%2C929127%2C929129%2C929131%2C929930%2C925720%2C925722%2C925718%2C929917%2C929919%2C929933%2C912521%2C919206%2C932306%2C913428%2C920605%2C904830%2C919373%2C930803%2C908536%2C904122%2C938701%2C911423%2C936308%2C909549%2C900816%2C912711%2C904494%2C904497%2C900375%2C906001&ipbits=8&ratebypass=yes&ip=31.170.160.74&key=yt1&ms=au&mv=u
[fallback_host] => tc.v23.cache8.c.youtube.com
[type] => video/webm; codecs=\"vp8.0, vorbis\"
[sig] => 1A6118D09B20DCD2CD068CAD2415C6BFF80FF5F0.5FB3424173B8FABE7379689138DFA7038B5F11B4
)
how can i put these informations together to make a valid download link ?
any help will be much appreciated and thanks in advance
The download url is already there in the result, for example :
http://r7---sn-25ge7n7l.c.youtube.com/videoplayback?source=youtube&expire=1377205488&cp=U0hWTFJLU19NUkNONl9KRVdFOlFROHcyQXZRVzMw&sver=3&mt=1377182899&itag=45&id=f3a24c732e4ea990&upn=aBSr1FoD9WM&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=919112%2C919363%2C914074%2C916624%2C909546%2C906397%2C929117%2C929121%2C929906%2C929907%2C929922%2C929127%2C929129%2C929131%2C929930%2C925720%2C925722%2C925718%2C929917%2C929919%2C929933%2C912521%2C919206%2C932306%2C913428%2C920605%2C904830%2C919373%2C930803%2C908536%2C904122%2C938701%2C911423%2C936308%2C909549%2C900816%2C912711%2C904494%2C904497%2C900375%2C906001&ipbits=8&ratebypass=yes&ip=31.170.160.74&key=yt1&ms=au&mv=u
will be the url you are looking for in above. This url will change with every request and also only available from the IP which requested it.

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.

Categories