Search Unity

FAcebook sharing score

Discussion in 'Editor & General Support' started by Zaskar7777, Sep 19, 2021.

  1. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    I have successfully implemented the Facebook SDK with Unity and can open the Facebook popup from Unity WebGL build and the user can type in a message and post it in their Facebook account.

    However, I am not able to send a custom message and score to the user's Facebook post.

    I tried using the following code.

    Code (CSharp):
    1.  
    2.  
    3. FB.ShareLink(contentTitle: "My Game Score", contentURL: new System.Uri("someurl"), contentDescription: "Here is my Score "+Score, callback: ONShare);
    4. void ONShare(IShareResult result)
    5.     {
    6.         if(result.Cancelled || string.IsNullOrEmpty(result.Error))
    7.         {
    8.             Debug.Log("Unity Error "+result.Error);
    9.         }else if (!string.IsNullOrEmpty(result.PostId))
    10.         {
    11.             Debug.Log("Unity Share successful");
    12.         }
    13.     }
    14.  
    And then I tried this when the above did not work.

    Code (CSharp):
    1.  
    2. FB.FeedShare(toId: "",link: new System.Uri("someurl"),linkName: "Here is my Score "+Score, callback: ONShare);
    3.         Debug.Log("Unity Share called ");
    4. void ONShare(IShareResult result)
    5.     {
    6.         if(result.Cancelled || string.IsNullOrEmpty(result.Error))
    7.         {
    8.             Debug.Log("Unity Error "+result.Error);
    9.         }else if (!string.IsNullOrEmpty(result.PostId))
    10.         {
    11.             Debug.Log("Unity Share successful");
    12.         }
    13.     }
    14.  
    15.  
    I am not able to send the custom message "Here is my Score" and the Score itself.

    It does open the Facebook popup however the custom message and score cannot be seen anywhere while sending the post.

    Thanks
    Zaskar
     
    Last edited: Sep 19, 2021
  2. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    Are these methods FeedShare and ShareLink deprecated?

    Will Graph API help here? in which case I will have to go the Unity to Javascript through jslib and then Javascript to Facebook integration using FaceBook javascript SDK and Graph API calls.