Search Unity

Facebook SDK: How to create a objectId in c#?

Discussion in 'Formats & External Tools' started by Staakman, Apr 18, 2014.

  1. Staakman

    Staakman

    Joined:
    May 15, 2013
    Posts:
    10
    Hey developers,

    I'm trying to implement the facebook SDK into a little game I'm working on.
    I've downloaded the latest version of the Facebook SDK for Unity3D (version 5.1).

    Now I would like to make a 'AppRequest' (ask for help) which uses an actiontype and a objectid.
    How do I get an objectid?

    Code (csharp):
    1.  
    2. FB.AppRequest(
    3.             DirectRequestMessage,
    4.             DirectActionType,
    5.             objectId: "YOUR_OBJECT_ID", // <--- how do I get an valid object id?
    6.             filters: "",
    7.             excludeIds: null,
    8.             maxRecipients : null,
    9.             data: "{\"some data\":",
    10.             title: "awesome title",
    11.             callback: RequestKeysCallback
    12.             );
    13.  
    EDIT: nevermind, I figured it out, there's a tool which allows you to create objects.
     
    Last edited: Apr 18, 2014
  2. PavelLangweil

    PavelLangweil

    Joined:
    Mar 4, 2014
    Posts:
    28
    Thanks for mentioning th ename of the tool ..:)
     
  3. SavasAdar

    SavasAdar

    Joined:
    Jan 1, 2015
    Posts:
    1
  4. Saddamjit_Singh

    Saddamjit_Singh

    Joined:
    Dec 4, 2015
    Posts:
    22
    Hey everyone,

    Have you successfully created Object ID using Facebook Object browser?
    I think we need to create it by using Facebook API . I am using the code below but not getting ID in return-

    private static void GetOpenGraphObjectID()
    {
    var formDict = new Dictionary<string, string>()
    {
    {"title", "AskForCoins"},
    {"type", "product.item"},
    {"app_id", "921871194580745"}
    };
    var formData = new Dictionary<string, string>() { { "object", Facebook.MiniJSON.Json.Serialize(formDict) } };
    Debug.LogError (formDict.Values);
    FB.API("/me?objects/product.item", HttpMethod.POST, CreateFBLifeCallback, formData);
    }

    private static void CreateFBLifeCallback(IGraphResult result)
    {
    if (!string.IsNullOrEmpty(result.Error))
    {
    Debug.LogError("Error during object create call! " + result.Error);
    }
    else
    {

    Debug.LogError("result "+result.ResultDictionary.Values);
    object myID;
    if (result.ResultDictionary.TryGetValue ("id", out myID)) {
    Debug.LogError ("myID "+myID);
    }

    }
    }


    If someone ha solved this issue, please help.