Can anyone help me, i want to display the news feeds from a facebook page, that is also mobile safe, i want to develop a mobile application..
How would this be done, could you show me some example code? or point me to t tutorial or something???
All the help will be greatly appreciated.
The habit of changing everything is due to some guys creating scripts then posting it on http://userscripts.org
It was cool to see the script which lets you view photos of people who are not your friends.
If I had time i would work on these clever javascripts.
in that code you provided above, i just refered back to it realised i somehow managed to change it completely.
So all i have to do is display that code, decode it intto json and then put it into a text field? which thanks to the help of other people i understand now, but in that code where do i put my acess token????
So all i have to do is display that code, decode it intto json and then put it into a text field? which thanks to the help of other people i understand now, but in that code where do i put my acess token????
Facebook returns the data in JSON so you will need to decode it using JSON class by Mike Chambers, just like the way I showed to you for Twitter.
Unlike Twitter, Facebook JSON data is Object so cast the decoded data to Object.
The other difference is that Facebook data is little more complex than Twitter data - there are Likes, comments, Likes to a comment, comments to a comment, etc - so the parsing is little more involved.
Access Token is needed when you call the API. I already showed it to you in my previous post ![]()
kennethkawamoto2: Can you show me how to do this? I have really been trying so hard to find out how to do this, i have actually truly tried on my own before seeking help. All the tutorials on the internet show how to do login systems ect. I just want to display the news feeds from a fan page.. PLEASE HELP ME ![]()
i dont know, because i dont understand much about the code above ? i mean i get the url loader bit, then where do i put my id ect?
how do i call the feed from the API, if i know that then i can display it into a text field my self.
Can you show me how to decode it into JSON?
There isn't much to it... Say the Page your accessing has the ID 12345678910, and the Access Token you obtained is 123456789123456|aBcDefgHiJKl_12a3C4DE5F6GH, your call to the API would be:
https://graph.facebook.com/12345678910/feed?access_token=123456789123456|aBcDefgHiJKl_12a3C4DE5F6GH
haha i figured it out literally 10 secs before i read this, but now its displaying this:
"message": "Kissstory on the way to Eaton Sports Therapy sesh, yeeeeea. Brno MotoGP from Friday, nice little break :)",
"type": "status",
"application": {
"name": "Facebook for iPhone",
"id": "6628568379"
},
well there is alot more than that but thats jsut a segmant. So how can i display just the news feeds from that?
so just what the API determines as "meassage:"
no its not the whole data displayed, if yo want me to show you it all i can? but its basically the same as that. But i want to format it i guess so it only shows the message.. Instead of all that data... Do you know how to do this, i just want to display the "message:" instead of all the data, like twitter you only want to display the tweets..
Ah sorry I misread your post - I thought that's all you received! So you received the JSON data, that's good ![]()
Then just decode it to an AS object. Facebook data object has "data" key, whcih holds an Array of wall posts. Once you get to that Array just iterate it to extract the messages.
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import com.adobe.serialization.json.JSON;
var loader:URLLoader = new URLLoader(new URLRequest("https://graph.facebook.com/XXX/feed?access_token=XXX"));
loader.addEventListener(Event.COMPLETE, loadComplete);
function loadComplete(e:Event):void {
processData(e.target.data);
}
function processData(data:String):void {
var facebookFeed:Array = JSON.decode(data).data as Array;
for(var i:uint, feedCount:uint = facebookFeed.length; i < feedCount; i++){
trace(facebookFeed[i].message);
}
}
You should get a bunch of messages in trace.
THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, THANK YOU!, Dude you really helped me out man! I Appreciate it more than you can imagine! Thanks!!!
There are so many different ways to display this data and it's all down to how you want to display. I show you the most rudimentary way here with a TextField:
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import com.adobe.serialization.json.JSON;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
var textfield:TextField = new TextField();
with(textfield){
x = 10;
y = 10;
width = 400;
autoSize = TextFieldAutoSize.LEFT;
wordWrap = true;
multiline = true;
}
addChild(textfield);
var messages:String = new String();
var facebookAPI:String = "https://graph.facebook.com/XXX/feed?access_token=XXX";
var loader:URLLoader = new URLLoader(new URLRequest(facebookAPI));
loader.addEventListener(Event.COMPLETE, loadComplete);
function loadComplete(e:Event):void {
processData(e.target.data);
}
function processData(data:String):void {
var facebookFeed:Array = JSON.decode(data).data as Array;
for (var i:uint, feedCount:uint = facebookFeed.length; i < feedCount; i++) {
// trace(facebookFeed[i].message);
messages += facebookFeed[i].message + "\n\n";
}
textfield.text = messages;
}
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import com.adobe.serialization.json.JSON;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.geom.Point;
var positions:Vector.<Point> = new Vector.<Point>();
positions.push(new Point(20, 90));
positions.push(new Point(20, 140));
positions.push(new Point(20, 190));
positions.push(new Point(20, 240));
positions.push(new Point(20, 290));
positions.push(new Point(20, 340));
positions.push(new Point(20, 390));
var facebookAPI:String = "https://graph.facebook.com/XXX/feed?access_token=XXX";
var loader:URLLoader = new URLLoader(new URLRequest(facebookAPI));
loader.addEventListener(Event.COMPLETE, loadComplete);
function loadComplete(e:Event):void {
processData(e.target.data);
}
function processData(data:String):void {
var facebookFeed:Array = JSON.decode(data).data as Array;
for (var i:uint, feedCount:uint = 7; i < feedCount; i++) {
var textfield:TextField = new TextField();
with(textfield){
x = positions[i].x;
y = positions[i].y;
width = 400;
autoSize = TextFieldAutoSize.LEFT;
wordWrap = true;
multiline = true;
text = facebookFeed[i].message;
}
addChild(textfield);
}
}
Hi, this is really clear and concise. It is so easy to understand.
I wonder if you have a similar piece of code - as easy as this, that shows me how to post a pre-formatted message to my page?
I want to be able to post my geiolocation to my facebook page from the press of a button.
Of course there is a lot more code related to this, but consider this pseudo code for this question.
[Send to Facebook]
sendToFacebook(); {
location = "http://maps.google.com/maps?q=38.714008,+-122.41675&iwloc=A&hl=en&ll=3 7.714008,-122.4167&output=embed&z=13";
/* authorize */
/* send the location string to facebook page */
/* return */
}
This is probably too much to ask, sorry, but your code is really clear, so I just thought I'd ask.
Thanks
Robert
Do you mean you want to post a link to Google Maps to your wall? If so you'd POST message=
"http://maps.google.com/maps?q=38.714008,+-122.41675&iwloc=A&hl=en&ll=3 7.714008,-122.4167&output=embed&z=13" to https://graph.facebook.com/PROFILE-ID/feed
See http://developers.facebook.com/docs/reference/api/
--
Kenneth Kawamoto
North America
Europe, Middle East and Africa
Asia Pacific