- Home /
I just want to post a score to Facebook from Android....
I've been working for two days straight trying to get this mess to work, and I've found nothing but complicated 'tutorials' and people just directing to the totally non-comprehensive walkthroughs Facebook has for their APIs. Needless to say, I'm very frustrated.
I seem to have everything functioning on the editor player, although it's just using a temporary token and not an actual Facebook login. When I try to do it on the Android device, it's a disaster.
It never asks for a dialog to allow permissions for the app like I imagine it should.
When I try to login it takes me to a browser Facebook page, and it has a pink error message saying, "The page you requested cannot be displayed right now. It may be temporarily unavailable [etc., etc.]"
I think part of the problem is that it's not actually connecting correctly to the Facebook App I made for it. I went through so many steps (NOT mentioned on the Facebook API documentation, I should add), including generating a keystore, installing Java SDK, installing OpenSSL, changing system path variables.
It's confusing, because the Facebook documentation for the Android section tells how to do a lot of this stuff, but the problem is that it is talking about implementing them into Android projects made from scratch in Eclipse, not with Unity. It's as if they have no information on implementing it into Android, built with Unity.
Please help me, I'm really completely lost with this mess, and please, PLEASE do not just link me to the Facebook API documentation as a solution. This is becoming a nightmare, and I'm starting to think it's not even worth this trouble. After all, I am literally only trying to post a score to the player's Facebook page, that's it.
Answer by aqib · Mar 29, 2014 at 12:49 PM
First, Check if your Facebook app is in sandbox mode. If it is, then you will not be able to post from a different id except the one you have opened the app from. It may cause you temporarily unavailability error. And there is a way of doing it without Facebook API. the script is given below:
public class ShareButton : MonoBehaviour
{
public Texture usual;
public Texture clicked;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
foreach (Touch touch in Input.touches) {
Ray ray = Camera.main.ScreenPointToRay (touch.position);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast (ray, out hit, 600.0f)) {
if (hit.collider.name.ToString () == "Share Button") {
Debug.Log ("Share Button");
if (touch.phase == TouchPhase.Began) {
this.renderer.material.mainTexture = clicked;
}
if (touch.phase == TouchPhase.Ended) {
this.renderer.material.mainTexture = usual;
string AppId = "<Your App Id>";
string Link = "<Link of your app>";
string ImageLink = "<Link of the image you want to share with the post>";
string Name = "<Your App Name>";
string Caption = "<Caption>";
string Description = "<Details About the post>";
string shareUrl = "https://www.facebook.com/dialog/feed?_path=feed&app_id="+AppId+"&link=" + Link + "&picture=" + ImageLink + "&name=" + Name + "&caption=" + Caption + "&description=" + Description + "&redirect_uri=https%3A%2F%2Fwww.facebook.com";
Application.OpenURL (shareUrl);
}
}
}
}
}
}
It will take you to the browser, ask for permission to post. then, if you press back button, you will come back to your app. You can try it, if you want.
You are using these methods rite...
1.FB.Init(OnInitComplete, OnHideUnity);
2.FB.Login("publish_actions",loginCallBack);
3.FB.API();
if yes then i can help
@aqib: Thanks! I'll do that for a temporary fix if I have to. :)
@Noob_Vulcan: Yes, I'm using those methods.
Your answer
Follow this Question
Related Questions
Importing Facebook SDK on project makes the build crash on Android 2 Answers
Share screenshot of game to Facebook with title and description 0 Answers
Facebook Deep Link in Unity3D equal to null 0 Answers
Facebook - Is it possible to logout other active sessions? 0 Answers
Simple Unity3d Facebook Integration? 1 Answer