简体   繁体   中英

Unity Facebook integration - Screenshot posting Issues

I have been searching for a week now how to post a screenshot from Unity on Facebook timeline.

Where I got so far:

  • I can take the screenshot
  • I can upload it to an album with the FB.API()
  • I can squeeze out the photoID from the Callback

The problem starts when im trying to use that photoID

A few things to understand the situation:

  • copy/paste the above mentioned url with the photoID from my FB.API() uploaded pic brings me to the correct picture in a browser.

  • but trying the same link in Unity results in a questionmark (pic not found I guess)

  • Using the permalink of the picture works perfectly in Unity, but that way I cannot refer to it with a PhotoID (I have also looked into the permission issues, and I am using a temporary token that allowes me to do publish_actions )

My goal is: I want to post a screenshot from Unity using facebook SDK on the user's timeline. I am going to use Unity WebGL.

Edit: Following the advise of CBroe I am going to do my research on the Open Graph markup solution for the post, I will keep the thread posted.

I have found the answer to my own question:

So with the real URL of any picture on facebook you can do a FB.FEED() As you can read it in the comments above, be sure that your app does not spam the timeline of the user. best follow the advices of CBroe. But if you are still interested in how exactly can you get the actual URL here are my step by step instructions:

  1. Get the photo ID you need the real URL of (usually the callback result contains it).
  2. Use the FB.API("YOUR_PHOTO_ID?fields=source", Facebook.HttpMethod.GET, YourCallBack);
  3. In the YourCallBack function the FBResult will contain a JSON object that has your real URL under the source key.
  4. If you know how to deserialize a JSON string to a Dictionary, then do so, if not Google it :D, or download the Util.cs that contains deserializing scripts. The way I got to the source was that I have edited the Util.cs because the DeserializeJSONProfile function focuses on the "first_name", so copy/paste the function rename it to DeserializeJSONSource, and change the "fist_name"s to "source". Then call this from Unity Util.DeserializeJSONSource(YOUR_FBRESULT.Text).

and there you go the dictionary you are assigning the result too will contain the key : "source".

(I was trying to get the same source info while doing the FB.API() posting too, but I could not squeeze it out.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM