Search Unity

Need help with Facebook Integration

Discussion in 'Scripting' started by Deleted User, Jun 21, 2015.

  1. Deleted User

    Deleted User

    Guest

    Hi all.

    I try to use the last facebook sdk and have a lot of problems and bug. There is a unity plugin for facebook or its olny the facebook sdk? anyone has a tutorial of how to implement that?

    thanks
     
  2. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845
    There is alot of tuts on how to add Facebook. Follow them step by Step let us know the issues your having then maybe we can help, make sure you download the SDK first..
     
  3. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    I know it costs money but the prime 31 plugin is really easy to use when adding Facebook support
     
  4. Deleted User

    Deleted User

    Guest

    nice thanks!
     
  5. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    Definitely recommend the Prime 31 plugin for social media integration. They are on top of their products and have plugins that just work.
     
    Deleted User likes this.
  6. Deleted User

    Deleted User

    Guest

    thanks guys, but i need something free, dont have money at the moment =/
     
  7. Deleted User

    Deleted User

    Guest

    @Recon03

    this is the errors when I try to share something with facebook sdk. another error, is the size os facebook window. theres a way to fit to my screen size?

    facesdkerror.png

    and here is my code. I put this script on an empty gameobject

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class FBscript : MonoBehaviour {
    5.  
    6.     void Awake(){
    7.         FB.Init(SetInit, OnHideUnity);
    8.     }
    9.     // Use this for initialization
    10.     void Start () {
    11.  
    12.  
    13.     }
    14.    
    15.     // Update is called once per frame
    16.     void Update () {
    17.    
    18.     }
    19.  
    20.     public void ShareButton(){
    21.         if(FB.IsLoggedIn) {
    22.             FB.Feed(linkCaption:"loren ipsum",
    23.                     picture: "",
    24.                     linkName: "download now!",
    25.                     link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
    26.                     );
    27.         } else {
    28.             FB.Login("email", AuthCallback);
    29.         }
    30.     }
    31.  
    32.     private void SetInit() {
    33.         enabled = true;
    34.         // "enabled" is a magic global; this lets us wait for FB before we start rendering
    35.     }
    36.    
    37.     private void OnHideUnity(bool isGameShown) {
    38.         if (!isGameShown) {
    39.             // pause the game - we will need to hide
    40.             Time.timeScale = 0;
    41.         } else {
    42.             // start the game back up - we're getting focus again
    43.             Time.timeScale = 1;
    44.         }
    45.     }
    46.  
    47.     void AuthCallback(FBResult result){
    48.         if (FB.IsLoggedIn) {
    49.             Debug.Log("logged");
    50.         }
    51.         else {
    52.             Debug.Log("fail");
    53.         }
    54.     }
    55.  
    56. }
    57.  
    anyone can help me please
     
  8. BrokenhearT

    BrokenhearT

    Joined:
    May 18, 2015
    Posts:
    69
    You need a new access token yours has expired hit on access token that will transfer you to facebook developer account page and bring up a token copy it and paste it as login info then hit log in should do.

    let me know what happens.

    regards.
     
    Deleted User likes this.
  9. Deleted User

    Deleted User

    Guest

    Now I get another error... the access token window dont appear, and this error shown. anyone knows what is that?

    fberror.PNG

    in my code i just call the SetInit method

    Code (CSharp):
    1. public void SetInit(){
    2.  
    3.         if (FB.IsLoggedIn) {
    4.             OnLoggedIn();
    5.         }
    6.         else {
    7.             FBLogin();
    8.         }
    9.     }
    10.  
    11.     void FBLogin(){
    12.         FB.Login ("email", AuthCallback);
    13.     }
    14.  
    15.     void AuthCallback(FBResult result){
    16.         if (FB.IsLoggedIn) {
    17.  
    18.         }
    19.     }