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 CS0234 HttpMethod not found after upgrading to Facebook 7.2.0 SDK

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

  1. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    Hi everyone.

    I had a game I've been working on that was using the 6.2 Facebook SDK, and I upgraded the SDK to 7.2 today. I'm now getting some serious errors. I removed the 6.2 SDK completely from my assets, as per Facebook's upgrade guide, and when installing the new one, I don't get the Facebook menu like it says I should, but I assume that's due to compiler errors because of all the changes I'll have to make.

    My biggest error is the following:

    Assets/Scripts/FBMain.cs(42,72): error CS0234: The type or namespace name `HttpMethod' does not exist in the namespace `Facebook'. Are you missing an assembly reference?

    In FBMain.cs, I did make sure I added the Facebook.Unity namespace, so I'm not sure where my issue is or how to fix it. Any help would be greatly appreciated, and if I need to provide any code examples, let me know.
     
  2. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    In my FBMain.cs, where I've set all my code for working with the Facebook API, has the following set:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using Facebook.Unity;
    This *should* allow it to see my FB.cs, but it doesn't seem to be seeing that file since the upgrade. Is there something I'm missing possibly?
     
  3. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Can you post you code where the error occurs, the namespace seems to be correct but the method you are calling does not exist in FB 7.2.0.
     
  4. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    In the code below, right now it's anything with a reference to HttpMethod, which seems to still be in the 7.2 standard.

    Code (CSharp):
    1. public void Start()
    2.     {
    3.         DontDestroyOnLoad (transform.gameObject);
    4.  
    5.         if (Application.loadedLevelName == "NormalMode") {
    6.  
    7.             if (FB.IsLoggedIn) {
    8.  
    9.  
    10.  
    11.  
    12.                     FB.API ("/me/scores", Facebook.HttpMethod.GET, delegate(IResult result) {
    13.                         if (result == null) {
    14.                             GameObject.FindGameObjectWithTag ("HighScoreText").GetComponent<Text> ().text = "High Score: 0";
    15.                         } else {
    16.  
    17.  
    18.                             myScore = Util.DeserializeScores (result.Text);
    19.                             Debug.Log (result.Text);
    20.  
    21.                             foreach (object score in myScore) {
    22.                                 var entry = (Dictionary<string, object>)score;
    23.                
    24.                                 Debug.Log (score);
    25.                                 GameObject.FindGameObjectWithTag ("HighScoreText").GetComponent<Text> ().text = "High Score: " + entry ["score"].ToString ();
    26.                
    27.                                 myHighScore = int.Parse (entry ["score"].ToString ());
    28.  
    29.                             }
    30.                         }
    31.                     });
    32.            
    33.                 } else {
    34.                     GameObject.FindGameObjectWithTag ("HighScoreText").GetComponent<Text> ().text = "High Score Unknown";
    35.                 }
    36.             }
    37.         }
     
  5. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Code (CSharp):
    1. Facebook.HttpMethod
    Assuming this is still correct, you need to add the Facebook namespace to your usings (you only have Facebook.Unity at the moment). Otherwise the method has been moved to the Facebook.Unity namespace in which case you can drop the Facebook prefix.
     
  6. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    The first line of FB.cs is "namespace Facebook.Unity".
     
  7. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    Facebook.HttpMethod is no longer valid. Just use HttpMethod.Get.
     
    firejerm, avivoren and Khoi-Hoang like this.
  8. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    Thanks Brathnann. That solved that particular problem.
     
    FunkyArmor likes this.
  9. avivoren

    avivoren

    Joined:
    Sep 21, 2014
    Posts:
    36
    Thank you! helped me alot :)
     
    firejerm likes this.
  10. FunkyArmor

    FunkyArmor

    Joined:
    Feb 27, 2021
    Posts:
    1
    Thank you so much this helped a ton!!!!