Display my Facebook wall posts

I’ve been looking at some examples on how to use facebook in your games, however most of the sample is on how to post score to your wall and I was looking for how to display my wall posts.

I’m pretty new at this so I took the tabBar sample and made a new module that would show my wall posts in one of the tabs.

I’m not sure on how to proceed further, I started out with a webView but that showed my entire profile and that was not what I had in mind. So I was thinking if I could add my wall post to a widget scrollView?

I thought this would be a fun thing to share with my friends since I don’t have a website or a blog so they could get my app instead.

After reading about FB graphs, that honestly didn’t make no sense to me. I did figured out I need to create an appID etc and so I did. FB uses json so I required that since it’s built into corona.

So now I have my appID, appSecret and a nameSpace. But what is an accessToken?

https://graph.facebook.com/me/feed?access_token=” Should I put my appID here?

I would be very thankful if anyone could help me out with this…

  
module(..., package.seeall)  
  
local facebook = require("facebook")  
local json = require("json")  
local widget = require("widget")  
  
function new()  
 local g = display.newGroup()  
 local background  
 local myScrollView = widget.newScrollView  
 local myAppID = "123456789"  
  
 background = display.newRect(0, 0, 320, 480)  
 background:setFillColor(255, 255, 255)  
 g:insert(background)  
  
 myScrollView = newScrollView{   
 x = 0,   
 y = 0,   
 width = 320 ,   
 height = 480,  
 }  
  
 g:insert(myScrollView.view)  
  
 facebook.login(myAppId, fbListener)  
  
 local function = fbListener(event)  
 if("session" == event.type) then  
 if("login" == event.phase) then  
 facebook.request("me/feed", "GET")  
 end  
 end  
 end  
  
  
 function g:cleanUp()  
  
 g:removeSelf();  
 g = nil;  
  
 print("cleaning");  
  
 end  
  
 return g  
end  

[import]uid: 65840 topic_id: 16161 reply_id: 316161[/import]

Also, another question.
Do I really need to make the user login to their FB account just to look at my wall? I understand they have to if they want to comment or like but since my profile is public then they shouldn’t need to login right?

So I would basically just add a login button to the toolBar to take care of that. [import]uid: 65840 topic_id: 16161 reply_id: 60139[/import]

It’s been a long time since I was involved in any FB development, but isn’t the access token provided by Facebook through their developer page? (ie: you access your dev page on facebook, grab the token from there and then insert it into your app.)

I really don’t know anything about graph these days but I have some vague recollection that that’s how tokens worked…

re: your second question; again, they’ve changed things a bit lately. I think for most users you can load their general page (I’ve never met this person before, but www.facebook/com/richard loads an actual page, for example) But I get the impression that walls are blocked unless you’re logged in. I could be wrong though - may want to google that a bit and/or try some guess pages. [import]uid: 41884 topic_id: 16161 reply_id: 60447[/import]

I could go with the webView if I only could isolate the wall posts, I don’t want the rest since I use my FB as a mini blog. I don’t think scrollView is the right way to do this unless someone else think it’s a good idea.

I was thinking of using tableView but is it possible to have floating tab height since all posts are of different size?

When using tableViews, can the subTitle be multi line and does it break lines automatic? [import]uid: 65840 topic_id: 16161 reply_id: 60485[/import]

Whoops. Well, here’s the core of all you need to know about Corona and Facebook tokens. It sounds like there is still some connectivity but you’d have to read the thread and its links to figure out what’s involved.

If by tableView you mean the template, no; the one that’s up there right now actually determines the tab height by way of an invisible image. You would need to alter the item entry code to handle variable data.

The subtitle isn’t very difficult to customize but you have to line break manually (or find some way to use existing code samples for line breaking.)

[import]uid: 41884 topic_id: 16161 reply_id: 60491[/import]

you could probably use CSL paragraph for the subtitle. [import]uid: 13560 topic_id: 16161 reply_id: 60572[/import]

I decided to try what you are doing also but I want to have another persons feed so I decided to try with BlastMonkeys.
So after some reading, I managed to learn that I need to use the graph for BlastMonkeys wall feed

https://graph.facebook.com/BlastMonkeys/feed?access_token=

This seems to generate a json file but it looks really complicated to use as it is a bunch of real mumbo jumbo in it also.

I’m just curious, what is the best way to display this on the iPhone like Cindy said. Should we use a scrollView or a tableView?

If I would take a public profile such as LadyGaGas wall http://www.facebook.com/ladygaga?sk=wall , is there a way to just get that portion of her profile and use it with a webView?

The ideal way for this, like Cindy mentioned would be to have the your wall feed or like I’m trying to do BlastMonkeys, LadyGaGa or any other public profiles wall feed displayed when you switched to that tab. Then if you wanted to comment you press the login button and the FB login dialog would show and after login you could comment.

Another way would be that the facebook app would start and take you to that post you want to comment and if the app is not installed it would either open the appstore or facebook mobile page.

I’ll try writing some code and post it later, maybe we could try to solve this together Cindy?

It would be great if there could be some more focus on apps by ansca and perhaps add some more samples for Facebook.
[import]uid: 34126 topic_id: 16161 reply_id: 60591[/import]

Here’s what I have started, I found a post on the ansca blog by walter so I decided to make that sample with widgets but nothing is showing up.

sorry but I’m a bit confused after spending days to understand json and the facebook graph, it’s all a big mess in my head right now.

But in this test I’m trying to get a list of my friends in a widget tableview.

I can’t get the login button to work either, if you look at the code now it will login each time i press the facebook tab in my tabBar. However I found it a bit annoying to se the login dialog popup everytime and the fade away. What I had in mind was that the login button should be removed after successful login session but I haven’t gotten that far yet.

Also, If I want to have my wall feed displayed with out login how do I do that? I thought that if the user would actually be taken to the facebook app if they want to make a comment.

After looking at the wall feed graph, there’s a ton of stuff from friends posting things on my wall, I just want my postings. Is there a way to just just select my post to import into the tableview?

Can someone please help me?

[code]
module(…, package.seeall)

local facebook = require(“facebook”);
local json = require(“json”);

function new()
local g = display.newGroup()

local newToolbar = newToolbar;
local newButton = newButton;
local newScrollView = newScrollView;
local newTableView = newTableView;
local myNavBar = myNavBar;

– Vars
local myFBAppID = “232360718434165”

local myNavBar;
local myLogInBtn;
local navBarLogo;
local background;
local myTableView;
local items;
local item;

– Functions
local onFBLogIn;
local fbListener;

background = display.newRect(0, 0, 320, 480)
background:setFillColor(0)
g:insert(background)


onFBLogIn = function(event)
if event.phase == “release” then

–facebook.login( myFBAppID, fbListener )
print( " --> You pressed " … event.target.id )
end
end

– listener for “fbconnect” events
fbListener = function(event)
if ( “session” == event.type ) then
– upon successful login, request list of friends
if ( “login” == event.phase ) then
facebook.request( “me/friends” )
end
elseif ( “request” == event.type ) then
– event.response is a JSON object from the FB server
local response = event.response

– if request succeeds, create a scrolling list of friend names
if ( not event.isError ) then
response = json.decode( event.response )

local friends = {}
local data = response.data
for i=1,#data do
local name = data[i].name
table.insert( friends, name )
end
– create the list of items

item = {
icon = {
image = nil,
width = nil,
height = nil,
paddingTop = nil,
paddingRight = nil
},
title = friends,
subtitle = nil,
onRelease = nil,
onLeftSwipe = nil,
onRightSwipe = nil,
hideArrow = true
}

items[i] = item
end

myTableView = newTableView {
y = 64,
rowHeight = 60,
height = 367,
width = 320,
backgroundColor = “none”,
mask = “assets/mask-371.png”,
}
g:insert( myTableView.view);
myTableView:sync(items)

elseif (“dialog” == event.type) then
print(“dialog”, event.response)
end
end

facebook.login( myFBAppID, fbListener )

myNavBar = newToolbar (“Facebook”);
g:insert(myNavBar.view);

– Login button for facebook.
myLogInBtn = newButton{
id = “fbLogInBtn”,
label = “Login”,
x = display.contentWidth - 65,
y = 27,
onEvent = onFBLogIn,
}
myLogInBtn:setReferencePoint(display.TopLeftReferencePoint);
g:insert( myLogInBtn.view );


– Remove all object on screen/tab transition.
function g:cleanUp()

– Remove objects individually just incase.
display.remove(myNavBar);
display.remove(myLogInBtn);
display.remove(myTableView);

myNavBar = nil;
myLogInBtn = nil;
myTableView = nil;

– Remove the entire group.
g:removeSelf();
g = nil;

print(“clean and remove widgets”);

end

return g
end

[/code] [import]uid: 65840 topic_id: 16161 reply_id: 61423[/import]

Hey Cindy,

I see you’re making som progress.

I think that calling

facebook.request( "me/feed" )   

get your feed, I don’t know how to get others feed but I’m searching the forum for any hints.

Like you said, it would be real nice if the feed was already loaded in the tab and you only needed to login if you wanted to comment or “like”. Then if you wanted to check for new post, it would be real cool if there was a way to “pull to refresh”

I got inspired by your app idea and decided to make an app for my band, currently I’m learning how json works, I’ll dig into FB when I have a better understanding in that. [import]uid: 34126 topic_id: 16161 reply_id: 61460[/import]

I have another theory how to get someone else status updates, if you look at the URL of the users feed you wish to extract theres a string of numbers. I came across an article but for php and that guy put those numbers instead of “me” to get that done. So it would look something like this instead.

facebook.request( "134571234557422/feed" )   

You can check if that works for extracting others status updates. If this would work without having the user to login then it would be awesome, we could only make the user login if they want to make a comment and to make this easier we would just open the facebook app and direct them to the post on our wall or if they dont have the facebook app they would either be taken to appstore or open safari and facebook mobile version.

I was looking at your code and the login button, maybe it should be removed if the login was successful?

cheers,
David [import]uid: 34126 topic_id: 16161 reply_id: 61800[/import]