even if i go beyond and fix the table view…
i still can’t decode the facebook data properly … and get a uder ID from it…
do you have a code that can get me a User ID ?
becouse i can’t get it …never mind what i do … [import]uid: 174056 topic_id: 32422 reply_id: 129218[/import]
Actually…
the Graph API call: “me/friends” can delivery you a table member called “picture” along with their name, username, userID, is your app installed, etc.
that member is either a table with a URL member or it’s just a string that contains the URL to their picture.
Feed that URL to network.download() or display.loadRemoteImage() and you’re good to go. This gets a 50x50 image. Naomi’s version may get to the larger picture.
I’m also using LFS to look in the caches directory to see if I have the image and make sure its not too old before I re-download it. [import]uid: 19626 topic_id: 32422 reply_id: 129228[/import]
I think I like Naomi’s URL’s better since I can get bigger pictures!
[import]uid: 19626 topic_id: 32422 reply_id: 129229[/import]
thnx, the thing is i tried it soo manny times…
can you PLEASE give me a code that works ? that can get me that picture ? or even the user ID ? PLS ?
i just need the syntex… i mean the code …
Please ???
[import]uid: 174056 topic_id: 32422 reply_id: 129230[/import]
local json = require("json")
local friends
local function listener( event )
if ( "session" == event.type ) then
-- upon successful login, request list of friends
if ( "login" == event.phase ) then
facebook.request( "me/friends", "GET" )
end
elseif ( "request" == event.type ) then
-- event.response is a JSON object from the FB server
local response = event.response
print( response )
friends = json.decode(event.response)
for i = 1, #friends do
print(friends[i].name, friends[i].id)
end
end
end
facebook.login( "1234567890", listener, {"publish\_stream"} )
where “1234567890” is your app ID.
In side the listener function for the elseif event.type == "request bit you end up with a big table of all your friends. Do with it what you want. [import]uid: 19626 topic_id: 32422 reply_id: 129238[/import]
first of all thank you … it’s really nice of you …
i added above… the function : local facebook = require (“facebook”)
becouse it writes me errors if it wasn’t there.
the thing is it just gives me a black screen in the xCode Simulator AND in the phone it doesn’t write anything…
just a black screen
nor does it shoes any of the prints… in the console window in the xcode orginizer.
and in the console window of my xCode idevice it just writes alllot of lines i don’t really understand.(made of allot of numbers and stuff)… and allways adds more lines…
tried it with 2 different idevices…
could it be somthing to do with my facebook bundle id ? or somthing with my facebook app ?
my app number is: 314542735310401
and the bundle id is: com.mars.games.hamama
ive given my app an iphone appsotre id of: 386517678
in my build.settings it looks like this :
settings = {
iphone = {
plist = {
UIApplicationExitsOnSuspend = false,
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb314542735310401”,
}
}
}
}
}
}
and i changed your code instead of “1234567890”, ive put “314542735310401”…
what else can i do ?
it still Doesn’t work … [import]uid: 174056 topic_id: 32422 reply_id: 129314[/import]
first of all thank you … it’s really nice of you …
i added above… the function : local facebook = require (“facebook”)
becouse it writes me errors if it wasn’t there.
the thing is it just gives me a black screen in the xCode Simulator AND in the phone it doesn’t write anything…
just a black screen
nor does it shoes any of the prints… in the console window in the xcode orginizer.
and in the console window of my xCode idevice it just writes alllot of lines i don’t really understand.(made of allot of numbers and stuff)… and allways adds more lines…
tried it with 2 different idevices…
could it be somthing to do with my facebook bundle id ? or somthing with my facebook app ?
my app number is: 314542735310401
and the bundle id is: com.mars.games.hamama
ive given my app an iphone appsotre id of: 386517678
in my build.settings it looks like this :
settings = {
iphone = {
plist = {
UIApplicationExitsOnSuspend = false,
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb314542735310401”,
}
}
}
}
}
}
and i changed your code instead of “1234567890”, ive put “314542735310401”…
what else can i do ?
it still Doesn’t work … [import]uid: 174056 topic_id: 32422 reply_id: 129314[/import]
i’d like to know the answer as well !!!
for me it doesn’t work aswell !!!..
[import]uid: 173648 topic_id: 32422 reply_id: 129383[/import]
i’d like to know the answer as well !!!
for me it doesn’t work aswell !!!..
[import]uid: 173648 topic_id: 32422 reply_id: 129383[/import]
Does anybody know ???
please ?
[import]uid: 174056 topic_id: 32422 reply_id: 129469[/import]
Does anybody know ???
please ?
[import]uid: 174056 topic_id: 32422 reply_id: 129469[/import]
You guys should check out the facebook developer site, in particular the “graph” api. How to do this stuff is documented there.
Anyway…
To expand on the help rob has already given, this should download the friend picture for you (untested code)
local json = require("json")
local friends
local function listener( event )
if ( "session" == event.type ) then
-- upon successful login, request list of friends
if ( "login" == event.phase ) then
facebook.request( "me/friends", "GET" )
end
elseif ( "request" == event.type ) then
-- event.response is a JSON object from the FB server
local response = event.response
print( response )
friends = json.decode(event.response)
for i = 1, #friends do
print(friends[i].name, friends[i].id)
local function uponPictureDownload( event )
if ( event.isError ) then
print ( "Network error - picture download failed" )
else
myImage = display.newImage( friends[i].id .. ".png", system.TemporaryDirectory, 100, 100 )
myImage.alpha = 0
transition.to( myImage, { alpha = 1.0 } )
end
end
-- download the friends picture
network.download( "https://graph.facebook.com/" .. friends[i].id .. "/picture?width=100&height=100", "GET", uponPictureDownload, friends[i].id .. ".png", system.TemporaryDirectory )
end
end
end
facebook.login( "1234567890", listener, {"publish\_stream"} )
[import]uid: 84637 topic_id: 32422 reply_id: 129705[/import]
In fairness Danny, with my years of experience, the Facebook API is not the clearest read in the world. It’s much better than say Amazon’s SimpleDB insanity, but the examples are not great and it takes some fortitude to get through it to make any sense.
A good example is the class name for Android apps. I would have never figured out that I was supposed to put com.ansca.corona.CoronaActivity in that field.
And now my epiphany moment was “wait? I can set width and height for the image?” I’m sure its documented, but before I would every learn that, they’ve either bored me to death or talked over my head with stuff I don’t understand before I would ever get to that moment.
So if this works and I can get larger square pictures, I’m going to be one very happy programmer… (or at least force it into a fixed size box!)
[import]uid: 19626 topic_id: 32422 reply_id: 129707[/import]
I share Rob’s feeling. And yeah, if the width & the height thing really work, I’d love to know. It would definitely help simplify things for me, and I’d rather not guestimate and scale the images based on detected device resolution the way I am handling it now. (And cropping the profile pix with mask does not always do justice to profile pix after all.)
Naomi
[import]uid: 67217 topic_id: 32422 reply_id: 129709[/import]
As far as i know the width/height should work.
I do agree that the facebook api they provide and there documentation could be a lot better.
I am personally just one of those stubborn people that keeps at something until I get it and only reach out in utter desperation (in other words I waste time making sense of i), I don’t like to be beaten 
[import]uid: 84637 topic_id: 32422 reply_id: 129710[/import]
You guys should check out the facebook developer site, in particular the “graph” api. How to do this stuff is documented there.
Anyway…
To expand on the help rob has already given, this should download the friend picture for you (untested code)
local json = require("json")
local friends
local function listener( event )
if ( "session" == event.type ) then
-- upon successful login, request list of friends
if ( "login" == event.phase ) then
facebook.request( "me/friends", "GET" )
end
elseif ( "request" == event.type ) then
-- event.response is a JSON object from the FB server
local response = event.response
print( response )
friends = json.decode(event.response)
for i = 1, #friends do
print(friends[i].name, friends[i].id)
local function uponPictureDownload( event )
if ( event.isError ) then
print ( "Network error - picture download failed" )
else
myImage = display.newImage( friends[i].id .. ".png", system.TemporaryDirectory, 100, 100 )
myImage.alpha = 0
transition.to( myImage, { alpha = 1.0 } )
end
end
-- download the friends picture
network.download( "https://graph.facebook.com/" .. friends[i].id .. "/picture?width=100&height=100", "GET", uponPictureDownload, friends[i].id .. ".png", system.TemporaryDirectory )
end
end
end
facebook.login( "1234567890", listener, {"publish\_stream"} )
[import]uid: 84637 topic_id: 32422 reply_id: 129705[/import]
In fairness Danny, with my years of experience, the Facebook API is not the clearest read in the world. It’s much better than say Amazon’s SimpleDB insanity, but the examples are not great and it takes some fortitude to get through it to make any sense.
A good example is the class name for Android apps. I would have never figured out that I was supposed to put com.ansca.corona.CoronaActivity in that field.
And now my epiphany moment was “wait? I can set width and height for the image?” I’m sure its documented, but before I would every learn that, they’ve either bored me to death or talked over my head with stuff I don’t understand before I would ever get to that moment.
So if this works and I can get larger square pictures, I’m going to be one very happy programmer… (or at least force it into a fixed size box!)
[import]uid: 19626 topic_id: 32422 reply_id: 129707[/import]
I share Rob’s feeling. And yeah, if the width & the height thing really work, I’d love to know. It would definitely help simplify things for me, and I’d rather not guestimate and scale the images based on detected device resolution the way I am handling it now. (And cropping the profile pix with mask does not always do justice to profile pix after all.)
Naomi
[import]uid: 67217 topic_id: 32422 reply_id: 129709[/import]
As far as i know the width/height should work.
I do agree that the facebook api they provide and there documentation could be a lot better.
I am personally just one of those stubborn people that keeps at something until I get it and only reach out in utter desperation (in other words I waste time making sense of i), I don’t like to be beaten 
[import]uid: 84637 topic_id: 32422 reply_id: 129710[/import]
And WOO HOO… if you pass a height and width of 100x100 you get a square image!!!
[import]uid: 19626 topic_id: 32422 reply_id: 129745[/import]