Hi Guys, First I working in android platform with Facebook SDK. All I want is to post the image into facebook timeline, I saw the way how FB.Feed working, it’s just taking the url image to post the link. But I have a different method I want to share my photo(screenshot taken inside the application) directly into Facebook with Hastag name like #Contest, #Complaints, #Goal, etc… I searched and they said I have to do this in one way which mean I can save my photo into some link with FB.API and use FB.Feed to call the link. But am confused actually I want to share my screenshot into facebook timeline, I want the way to do it. So far I used this unity scripts to share the image but it’s not working.
public void Share()
{
if(!ShareImage)
{
StartCoroutine(ShareImageShot());
}
}
IEnumerator ShareImageShot()
{
ShareImage = true;
yield return new WaitForEndOfFrame();
Texture2D screenTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true);
screenTexture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height),0,0);
screenTexture.Apply();
byte[] dataToSave = screenTexture.EncodeToPNG();
string destination = Path.Combine(Application.persistentDataPath, Screenshot_Name);
File.WriteAllBytes(destination, dataToSave);
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", dataToSave, "InteractiveConsole.png");
FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
}
private Texture2D lastResponseTexture;
private string lastResponse = "";
private string ApiQuery = "";
void Callback(FBResult result)
{
lastResponseTexture = null;
if (result.Error != null)
lastResponse = "Error Response:
" + result.Error;
else if (!ApiQuery.Contains(“/picture”))
lastResponse = "Success Response:
" + result.Text;
else
{
lastResponseTexture = result.Texture;
lastResponse = "Success Response:
";
}
}
There is no error, but when I press the share button nothing happened. please give me the correct way to do this.