Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 30, 2016 at 05:59 AM by Prasanna for the following reason:

Other

avatar image
0
Question by Prasanna · Jul 06, 2015 at 05:04 AM · facebookunity 4.6timelinesharepost

Post screenshot photo on facebook

Hi Guys, First I working in android platform with Facebook SDK. All I want is to post the image into facebook timeline, I saw the way how FB.Feed working, it's just taking the url image to post the link. But I have a different method I want to share my photo(screenshot taken inside the application) directly into Facebook with Hastag name like #Contest, #Complaints, #Goal, etc... I searched and they said I have to do this in one way which mean I can save my photo into some link with FB.API and use FB.Feed to call the link. But am confused actually I want to share my screenshot into facebook timeline, I want the way to do it. So far I used this unity scripts to share the image but it's not working.

 public void Share()
     {
         if(!ShareImage)
         {
             StartCoroutine(ShareImageShot());
         }
     }
 
     IEnumerator ShareImageShot()
     {
         ShareImage = true;
 
         yield return new WaitForEndOfFrame();
         Texture2D screenTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true);
         
         screenTexture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height),0,0);
         
         screenTexture.Apply();
         
         byte[] dataToSave = screenTexture.EncodeToPNG();
         
         string destination = Path.Combine(Application.persistentDataPath, Screenshot_Name);
         
         File.WriteAllBytes(destination, dataToSave);
         
         var wwwForm = new WWWForm();
         wwwForm.AddBinaryData("image", dataToSave, "InteractiveConsole.png");
         
         FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
 
     }
 
     private Texture2D lastResponseTexture;
     private string lastResponse = "";
     private string ApiQuery = "";
     void Callback(FBResult result)
     {
         lastResponseTexture = null;
         if (result.Error != null)
             lastResponse = "Error Response:\n" + result.Error;
         else if (!ApiQuery.Contains("/picture"))
             lastResponse = "Success Response:\n" + result.Text;
         else
         {
             lastResponseTexture = result.Texture;
             lastResponse = "Success Response:\n";
         }
     }

There is no error, but when I press the share button nothing happened. please give me the correct way to do this.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
1

Answer by Umresh · Jul 06, 2015 at 05:31 AM

You have to first login using

 FB.Login("public_profile,email,user_friends", LoginCallback);

LoginCallback you can check if successfully logged in or not using FB.IsLoggedIn is true then call FB.API

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Prasanna · Jul 06, 2015 at 06:06 AM 0
Share

I did this part and it's working successfully. I really don't know what happening in this condition, when i try debug it's working. But the condition is not working.

avatar image SarthakHShah7 · Apr 14, 2017 at 10:32 AM 0
Share

I am using facebook sdk version 7.2.2 and it has 2 way to login to facebook. FB.LogInWithReadPermissions and FB.LoginWithRightPermission. which one should I use to share game screenshot on facebook photo. Please help me. Thanks in advance.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I set text after name in Facebook share post? 0 Answers

Facebook share screenshot with link. 1 Answer

How to publish on Facebook from my game? 3 Answers

Capture Screenshot and post to facebook? 0 Answers

Post highscore to Facebook 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges