Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error CS1525 with FB.ShareLink

Discussion in 'Scripting' started by Reymus, Oct 17, 2015.

  1. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    So I'm pretty much new to the new Facebook SDK, and am having problems with the update to the API. The error I'm running across at the moment is:

    Assets/Scripts/FBMain.cs(178,43): error CS1525: Unexpected symbol `contentTitle', expecting `.'

    The code I'm having a problem with is as follows:

    Code (CSharp):
    1. FB.ShareLink (
    2.             new Uri ("http://roamsoftstudios.com/crystalcracker"),
    3.             string contentTitle = "Play Crystal Cracker Now",
    4.             string contentDescription =  "I just got a score of " + gameControllerObject.GetComponent<GameController>().score + " in Crystal Cracker! Can you beat me?",
    5.             new Uri photoURL ("http://roamsoftstudios.com/wp-content/uploads/2015/05/crystalcrackerscreen.png"),
    6.             FacebookDelegate<IShareResult> callback = null
    7.             );
    Any idea where I'm going wrong?
     
  2. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    As far as I can tell, I'm following the SDK example properly, so I'm not sure where I'm going wrong
     
  3. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Code (CSharp):
    1. string contentTitle = "Play Crystal Cracker Now";
    2. string contentDescription =  "I just got a score of " + gameControllerObject.GetComponent<GameController>().score + " in Crystal Cracker! Can you beat me?";
    3.  
    4. 1.FB.ShareLink (
    5.     new Uri ("http://roamsoftstudios.com/crystalcracker"),
    6.     contentTitle,
    7.     contentDescription,
    8.     new Uri photoURL ("http://roamsoftstudios.com/wp-content/uploads/2015/05/crystalcrackerscreen.png"),
    9.     FacebookDelegate<IShareResult> callback = null);
    This should work better. Idk how they show it in the example you are following, but you can not instantiate a variable in a constructor.
     
  4. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    So, with the above code, that corrected that, but now I'm getting:

    Assets/Scripts/FBMain.cs(183,40): error CS1525: Unexpected symbol `photoURL', expecting `(', `)', `,', `;', `[', `{', or `<operator>'
     
  5. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Look at the first parameter given in the ShareLink constructor and you have your answer for that error :)
     
  6. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    Think I got that one figured out.

    Updating from the 6.2 to 7.2 SDK has really messed me up. I don't have a strong understanding of programming yet, and the changes here are significant, but there isn't very good documentation of the new SDK yet, and no tutorials anywhere. I've got about 30 errors in my code that I haven't got a clue how to fix, so this is frustrating.

    Thanks for your assistance so far, Timelog.
     
  7. Swati_zynga

    Swati_zynga

    Joined:
    Jul 18, 2018
    Posts:
    1
    I am having issues with FB.ShareLink. I am using the following code:-
    FB.ShareLink(
    new Uri("https://apps.facebook.com/nameofapp"),
    "test",
    "testing",
    new Uri(url of the image),
    callback: ShareCallback);

    If I put some URL in contentURL. It is overriding the photoURL and some image is getting display from contentURL not from photoURL. I want to share photoURL image.
    Any help.
     
  8. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    No need to revive a 2 year old dead post. ShareLink doesn't work the same way and you need to look into metatags. Facebook I don't think has updated their sdk or docs about it, but there are other post about sharing on FB and how the change works.

    A brief idea is you create an html file that links to the image you want to share. This html file includes several metatags for the share info, which is where it gets the link to the image along with some of the text pieces.