Gamecenter: LoadPlayer Photo?

I’m trying to get the player picture in Gamecenter, but nothing happens.

Anyone know how to do this?

 local function requestPhotoCallback( event )  
 Photo = event.data.photo  
 end  
  
 local function requestCallback( event )  
 \_G.PlayerName = event.data.alias  
 \_G.PlayerID = event.data.playerID  
 gameNetwork.request( "loadPlayerPhoto",  
 {  
 playerID = \_G.PlayerID,  
 size="Small", -- "Small" or "Normal"  
 listener=requestPhotoCallback  
 })   
 end  
  
 local function finishAuth(event)  
 \_G.gamenetworkEnabled = event.data  
 gameNetwork.request( "loadLocalPlayer", { listener=requestCallback } )  
 end  
  
 function authorize()  
 gameNetwork.init("gamecenter", finishAuth)  
 end   
  
 authorize()  
  

Above is the code i use to authorize, get playerid, and request the photo. XCode console doesn’t give any errors, but I don’t know how to display that picture.

[import]uid: 50459 topic_id: 32094 reply_id: 332094[/import]

Nobody? Can anyone from Corona Labs explain me how to do this?

I looked at the documentation, but no examples there.
[import]uid: 50459 topic_id: 32094 reply_id: 127878[/import]

Hmm that should work - put a print in your requestPhotoCallback() to make sure that is being called properly.

From what I can see the display object should be safely stored in your Photo variable - ready to be inserted into a display group.

I have had this working in the past so unless something has changed I do know it’s possible. [import]uid: 33275 topic_id: 32094 reply_id: 127887[/import]

Photo = event.data.photo doesn’t work, I get a error:

Attempt to index global ‘Photo’ ( a nil value)

I printed 2 extra commands:

 print("errorCode: "..event.errorCode)  
 print("errorMessage: "..event.errorMessage)  

And I get:

Errorcode: 3
The requested operation could not be completed due to an error communicating with the server.

[import]uid: 50459 topic_id: 32094 reply_id: 127920[/import]

Ok, this is getting frustrating.

Nobody at Corona Labs can shed some light on this?

I mean its not that hard of a question, but it would be nice if somebody at Corona Labs would jump into this.

I guess the users are left in the dark…

[import]uid: 50459 topic_id: 32094 reply_id: 127985[/import]

I haven’t used this aspect of Game Center myself, but happy to try to help.

First, the problem doesn’t seem to be with the photo itself. Evidently, the request to Game Center is failing, as shown by your print statements. The fact that the photo object is nil is just a consequence of the fact that the request failed.

So, the question is, at what step in the Game Center authentication and login process is something going wrong? I would suggest spitting out the contents of the event variable in each of your callback functions to see whether each step is working or not. To do that, insert the following at the top of each of your callback functions:

[blockcode]
for k,v in pairs(event) do
print(k,v)
end
[/blockcode]

  • Andrew [import]uid: 109711 topic_id: 32094 reply_id: 127990[/import]

The last step is not working. I get the PlayerID and Playername without problems, but when using the LoadPlayerPhoto function, I always get a communication error.

[import]uid: 50459 topic_id: 32094 reply_id: 128002[/import]

Interesting. Your code looks right to me (comparing to the APIs), so perhaps it’s a bug. I’d suggest filing a bug report.

  • Andrew [import]uid: 109711 topic_id: 32094 reply_id: 128003[/import]

Nobody? Can anyone from Corona Labs explain me how to do this?

I looked at the documentation, but no examples there.
[import]uid: 50459 topic_id: 32094 reply_id: 127878[/import]

Hmm that should work - put a print in your requestPhotoCallback() to make sure that is being called properly.

From what I can see the display object should be safely stored in your Photo variable - ready to be inserted into a display group.

I have had this working in the past so unless something has changed I do know it’s possible. [import]uid: 33275 topic_id: 32094 reply_id: 127887[/import]

Photo = event.data.photo doesn’t work, I get a error:

Attempt to index global ‘Photo’ ( a nil value)

I printed 2 extra commands:

 print("errorCode: "..event.errorCode)  
 print("errorMessage: "..event.errorMessage)  

And I get:

Errorcode: 3
The requested operation could not be completed due to an error communicating with the server.

[import]uid: 50459 topic_id: 32094 reply_id: 127920[/import]

Ok, this is getting frustrating.

Nobody at Corona Labs can shed some light on this?

I mean its not that hard of a question, but it would be nice if somebody at Corona Labs would jump into this.

I guess the users are left in the dark…

[import]uid: 50459 topic_id: 32094 reply_id: 127985[/import]

I haven’t used this aspect of Game Center myself, but happy to try to help.

First, the problem doesn’t seem to be with the photo itself. Evidently, the request to Game Center is failing, as shown by your print statements. The fact that the photo object is nil is just a consequence of the fact that the request failed.

So, the question is, at what step in the Game Center authentication and login process is something going wrong? I would suggest spitting out the contents of the event variable in each of your callback functions to see whether each step is working or not. To do that, insert the following at the top of each of your callback functions:

[blockcode]
for k,v in pairs(event) do
print(k,v)
end
[/blockcode]

  • Andrew [import]uid: 109711 topic_id: 32094 reply_id: 127990[/import]

The last step is not working. I get the PlayerID and Playername without problems, but when using the LoadPlayerPhoto function, I always get a communication error.

[import]uid: 50459 topic_id: 32094 reply_id: 128002[/import]

Interesting. Your code looks right to me (comparing to the APIs), so perhaps it’s a bug. I’d suggest filing a bug report.

  • Andrew [import]uid: 109711 topic_id: 32094 reply_id: 128003[/import]