Error CS0234 HttpMethod not found after upgrading to Facebook 7.2.0 SDK

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.

In my FBMain.cs, where I’ve set all my code for working with the Facebook API, has the following set:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
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?

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.

In the code below, right now it’s anything with a reference to HttpMethod, which seems to still be in the 7.2 standard.

public void Start()
    {
        DontDestroyOnLoad (transform.gameObject);

        if (Application.loadedLevelName == "NormalMode") {

            if (FB.IsLoggedIn) {




                    FB.API ("/me/scores", Facebook.HttpMethod.GET, delegate(IResult result) {
                        if (result == null) {
                            GameObject.FindGameObjectWithTag ("HighScoreText").GetComponent<Text> ().text = "High Score: 0";
                        } else {


                            myScore = Util.DeserializeScores (result.Text);
                            Debug.Log (result.Text);

                            foreach (object score in myScore) {
                                var entry = (Dictionary<string, object>)score;
               
                                Debug.Log (score);
                                GameObject.FindGameObjectWithTag ("HighScoreText").GetComponent<Text> ().text = "High Score: " + entry ["score"].ToString ();
               
                                myHighScore = int.Parse (entry ["score"].ToString ());

                            }
                        }
                    });
           
                } else {
                    GameObject.FindGameObjectWithTag ("HighScoreText").GetComponent<Text> ().text = "High Score Unknown";
                }
            }
        }
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.

The first line of FB.cs is “namespace Facebook.Unity”.

Facebook.HttpMethod is no longer valid. Just use HttpMethod.Get.

3 Likes

Thanks Brathnann. That solved that particular problem.

1 Like

Thank you! helped me alot :slight_smile:

1 Like

Thank you so much this helped a ton!!!