- Home /
Facebook share an invite overload error
Hi guys, i'm having trouble with my invite and share buttons. unity won't build due to not having overloads for the functions.
i've attached the script im using below so if anyone can help find the issue that would be great. i've highlighted the part of code which the compiler doesn't like.
Here's the facebook manager script using UnityEngine; using System.Collections;
public class FacebookManager {
public static bool IsInitialized = false;
public static string Permissions = "basic_info,publish_actions";
public static void Initialize() {
if(!IsInitialized) {
FB.Init(() => { IsInitialized = true; }, (bool IsGameShown) => {
if(!IsGameShown) {
Time.timeScale = 0;
} else {
Time.timeScale = 1;
}
});
}
}
public static bool IsAuthenticated {
get {
return FB.IsLoggedIn;
}
}
public static void Authenticate() {
if(IsAuthenticated) {
Debug.Log("Facebook is already authenticated!");
return;
}
FB.Login(Permissions, (FBResult result) => {
if(result.Error != null) {
Debug.Log("Facebook Login Error: " + result.Error);
}
});
}
this is what the compiler doesnt like for the invite function public static void Invite(string inviteTitle, string inviteMessage) { if(IsAuthenticated) { FB.AppRequest(inviteMessage, null, "", null, null, "", inviteTitle, null); } else { AuthenticateAndInvite(inviteTitle, inviteMessage); } }
and this is what the compiler doesnt like for the share function public static void Share(string name, string caption, string description, string image, string url) { if(IsAuthenticated) { FB.Feed("", url, name, caption, description, image, "", "", "", "", null, null); } else { AuthenticateAndShare(name, caption, description, image, url); } }
private static void AuthenticateAndInvite(string inviteTitle, string inviteMessage) {
if(IsAuthenticated) {
Debug.Log("Facebook is already authenticated!");
return;
}
FB.Login(Permissions, (FBResult result) => {
if(result.Error != null) {
Debug.Log("Facebook Login Error: " + result.Error);
} else if(IsAuthenticated) {
Invite(inviteTitle, inviteMessage);
}
});
}
private static void AuthenticateAndShare(string name, string caption, string description, string image, string url) {
if(IsAuthenticated) {
Debug.Log("Facebook is already authenticated!");
return;
}
FB.Login(Permissions, (FBResult result) => {
if(result.Error != null) {
Debug.Log("Facebook Login Error: " + result.Error);
} else if(IsAuthenticated) {
Share(name, caption, description, image, url);
}
});
}
}
Here is the invite script
using UnityEngine; using System.Collections;
public class FacebookInvite : MonoBehaviour {
void Update () {
if(isTouched()) {
FacebookManager.Invite("Play Zombies with me!", "Check out this new game.");
}
}
public bool isTouched() {
bool result = false;
if(Input.touchCount == 1) {
if(Input.touches[0].phase == TouchPhase.Ended) {
Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
Vector2 touchPos = new Vector2(wp.x, wp.y);
if (collider2D == Physics2D.OverlapPoint(touchPos)) {
result = true;
}
}
}
if(Input.GetMouseButtonUp(0)) {
Vector3 wp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePos = new Vector2(wp.x, wp.y);
if (collider2D == Physics2D.OverlapPoint(mousePos)) {
result = true;
}
}
return result;
}
}
and here is the share script
using UnityEngine; using System.Collections;
public class FacebookShare : MonoBehaviour {
void Update () {
if(isTouched()) {
FacebookManager.Share("Check out my latest run of zombies!", "I have a high score of " + (PlayerPrefs.GetInt("highscore", 0)).ToString() + " points. Can you beat me?");
}
}
public bool isTouched() {
bool result = false;
if(Input.touchCount == 1) {
if(Input.touches[0].phase == TouchPhase.Ended) {
Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
Vector2 touchPos = new Vector2(wp.x, wp.y);
if (collider2D == Physics2D.OverlapPoint(touchPos)) {
result = true;
}
}
}
if(Input.GetMouseButtonUp(0)) {
Vector3 wp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePos = new Vector2(wp.x, wp.y);
if (collider2D == Physics2D.OverlapPoint(mousePos)) {
result = true;
}
}
return result;
}
}
thanks in advanced
your highlighting of the potentially erroneous code has destroyed the formatting making it extremely hard to read. consider fixing it... also, what are the specific error messages (with line numbers)?
Answer by digibawb · Sep 07, 2014 at 05:58 PM
The latest Facebook SDK changed the AppRequest method, so the 3rd parameter is now a list of objects, not a string, so what you are passing is no longer valid (assuming you're on the 6.0 SDK anyway!).
The documentation still references the old version, unfortunately.
The FB.Feed looks correct to me at a glance, but you might want to check against what that method expects as well.
Answer by Mirakulous · Sep 07, 2014 at 08:02 PM
sorry this is the error i get
error CS1501: No overload for method AppRequest' takes
8' arguments
Your answer
Follow this Question
Related Questions
Facebook SDK Multi-friend-selector 1 Answer
Openssl not found in unity sdk for facebook 6 Answers
Facebook SDK focus. 1 Answer
Multiple Cars not working 1 Answer
I can see/send invites to non-app user friends on canvas app but not on android/ios 0 Answers