I have a flash game embedded on Facebook but need access to the flashvars facebook passes to all embedded games. However I am using the mochiads preloader meaning that _root.fb_sig_user is always undefined?
How do I get to the variables?
stage.loaderInfo.parameters.fb_sig_user
Was my best guess and it doesn't seem to have worked.
Try this..
paramList = LoaderInfo(this.root.loaderInfo).parameters;
trace(paramList["fb_sig_user"];
fb_session = new FacebookSessionUtil("api_key","api_secret", stage.loaderInfo);
Related
I am trying to fetch the first images on a Facebook Page. It works on other websites - using:
$image = $doc->getElementsByTagName('img')->item(0);
But for some reason, Facebook have wrapped in the 's i need, like this:
<code class="hidden_elem" id="u_0_7"><!-- <div class="timelineLoggedOutSignUp"><div class="_5h60" id="pagelet_loggedout_sign_up" data-referrer="pagelet_loggedout_sign_up"></div></div><div class="fbTimelineTopSectionBase fbTimelineLoggedOutTopSection"><div class="_5h60" id="pagelet_above_header_timeline" data-referrer="pagelet_above_header_timeline"></div><div id="above_header_timeline_placeholder"></div><div class="fbTimelineSection mtm fbTimelineTopSection"><div id="fbProfileCover"><div class="cover" id="u_0_4"><a class="coverWrap coverImage" href="https://www.facebook.com/photo.php?fbid=632540440113248&set=a.540825239284769.1073741827.540818775952082&type=1" rel="theater" ajaxify="https://www.facebook.com/photo.php?fbid=632540440113248&set=a.540825239284769.1073741827.540818775952082&type=1&src=https%3A%2F%2Fscontent-b.xx.fbcdn.net%2Fhphotos-ash3%2F579116_632540440113248_872174037_n.png&size=851%2C315&source=10" title="Coverbillede" id="fbCoverImageContainer"><img class="coverPhotoImg photo img" src="https://scon
Note that it is wrapped into a: <!-- -->.
Is there some way I can avoid this? Maybe changing the user-agent to an older browser, where they dont use the <!-- --> wraps? I can do this, using CURLOPT_USERAGENT in my CURL settings.
Any ideas? I am quite lost here..
All of this data is available via the Facebook Graph API so you don't need to fiddle around with the DOM or scrape the page - and you don't need to be authenticated to get it. This means you don't need Facebook's SDK or need to worry about registering an application if you are just grabbing public info. Also, Facebook change their HTML all the time so scraping the content will slowly drive you mad.
A quick JS example below, this gets the cover photo for your page:
$('#GetCoverImage').click(function() {
$.getJSON(
'https://graph.facebook.com/EduKarmaDK',
function(pageData) {
console.log(pageData.cover.source);
}
);
});
Other public info about the page is available in the pageData object. Have a play around with the Graph API Explorer to see what else is available.
PHP example:
<?php
$pageData = json_decode(
file_get_contents('https://graph.facebook.com/EduKarmaDK')
);
echo($pageData->cover->source);
my facebook application is posting an SWF on user wall the SWF is created in PHP with Ming (good decision?)
I want to make a button that switch the view to full screen mode, do you know how I can do it?
Can't mark this as dupe because of the bounty, so:
Make sure you have 'allowFullScreen' as true in your flash parameters
Create a button whose code is:
stage.displayState = StageDisplayState.FULL_SCREEN;
See Adobe's Docs for more information
You can't, Facebook is blocking you doing that. In order this to work you need just like #lgy says to set <param name="allowFullScreen" value="true" />. Facebook will not let you doing it, they only load your swf when user click on it(So the swf files will not be able to play any sound like it was in the old Facebook days) and they will set this parameter to false.
You could try the following code:
$m = new SWFMovie();
// your code here..
$m->add(new SWFAction("stage.displayState = 'fullScreen';"));
$m->nextFrame();
// your code here
We are stuck into a scenario where the Facebook app we just finished building has to reside inside of a parent iFrame. (This was an unknown to us until now)
We are wondering if there is an way to easily build the PHP Facebook Object and the JavaScript Facebook Object by only using the 'signed_request' token.
If not, would it make any sense to try and get the parent iFrame to send us the facebook cookies somehow and us setting those same cookies and then trying to build the objects?
Any help on this would be extremely appreciated as we are stuck very few days before launching.
The Facebook object is constructed locally. It desn't even need a signed_request.
I believe it will be enough to pass the signed request as $_GET parameter to internal frame so Facebook class can pick it from there:
public function getSignedRequest() {
if (!$this->signedRequest) {
if (isset($_REQUEST['signed_request'])) {
$this->signedRequest = $this->parseSignedRequest(
$_REQUEST['signed_request']);
} else if (isset($_COOKIE[$this->getSignedRequestCookieName()])) {
$this->signedRequest = $this->parseSignedRequest(
$_COOKIE[$this->getSignedRequestCookieName()]);
}
}
return $this->signedRequest;
}
setAccessToken is a public function, so it would be no problem to use it as well if you need an access token.
Sadly I'm not good enough to give you an advice for JavaScript :(
I render the page corretly, display images etc. But when the user changes the album selection I want to use ajax to refresh the div.
My problem is that when I send the call to the server it gets an exception since the facebook objects are dead/no-reference, I don't know.
I tried to save them with session_start. I can pass strings like this but if I pass the objects like this than calling them still fails:
$albumID = $_GET['album'];
$facebook = $_SESSION['fb'];
$albums = $_SESSION['albums'];
$tester = $_SESSION['tester']; //works fine
echo get_pictures_from_album($facebook, $albums, $albumID);
I would also reallt appriciate it if someone can refer me to good documentation. It seems that facebook only have examples for the simple, trivial issues but no complicated apps.
If you are storing an object in the session, you need to make sure you require the file containing the class definition before you call session_start. Otherwise PHP won't be able to deserialize the objects from the session correctly.
I want to connect to public facebook page or group and list all entries from the wall on a personal website. I will use PHP on my server so that would be the best solution for me. Or javascript.
Could anyone explain or perhaps give a working code on how to do this? Or just all steps nessesary for making this?
If its possible to handle information about person, date, description ... for each post, that would be great! So my layout could be customized.
Thanks for helping me out here!
You need to run FQL on stream table and provide id of a page or group you are interested in as source_id (fb docs have some explanation and examples). Once you get stream data you can dig deeper and get user who left this post or any other data you need again through FQL.
There are many ways of running FQL - it could be done in JS API, PHP API, or through old REST API.
use the facebook graph api urls that they provide
python code using simplejson parser
keyword="old spice"
searchurl='http://graph.facebook.com/search?q='+keyword
resp=urllib2.urlopen(searchurl)
pageData=resp.read()
json = simplejson.loads(pageData)
posts=json['data']
for p in posts:
postid=p['id']
username=p['from']['name']
posterimg=p['icon']
comment=p['message']
In JavaScript (jQuery).
You can use my spare access_token for viewing public groups or pages ;)
To get your own access token the facebook graph explorer can generate one for you (as well as test queries).
In Javascript we make a request to facebook graph, which returns a JSON object. The response looks like this.
The code below iterates though each entry and prints out the message, if you look at the link above it gives you the naming convention for the other data fields.
for example:
data.data[0].created_time;
data.data[0].from.name;
etc..
Hope that Helps!
<!DOCTYPE html>
<head>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
</head>
<body>
<ul id = 'list'>
<script>
var graphQuery = 'https://graph.facebook.com/2228101777/feed';
var authToken = '145634995501895|477bb3c939123a5845afe90d.1-100002565213903|F1VA26jsYL7yBeq2iU6SZX_XXrs'
var url = graphQuery +'?access_token='+ authToken +'&callback=?';
$.getJSON(url,function(data){
for( i=0; i < data.data.length; i++){
$("#list").append('<li>'+ data.data[i].message +'</li>');
// add some more here if needed
}
});
</script>
</ul>
</body>
</html>
What you are talking about, as far as I can tell, is Web Scraping. What you would do is get the URL of the group, use the file_get_contents($url) command in PHP to get the file, and then analyze it in PHP.
I'd suggest brushing up on your regular expressions for this, as it'll be important to review the HTML that Facebook uses for the wall posts. You'll be able to get the information that you're looking for from the HTML.
I would post some example code, but that's on another computer, far far away. Still, should be a good start.
Edit: Adding in some example code:
$URL = "http://facebook.com/group=5343242" (or whatever the URL structure is for the facebook group)
$groupPage = file_get_contents($URL)
Here's the link to the PHP pages on Regular Expressions:
http://www.php.net/manual/en/book.pcre.php