4

사진을 찍어서이 그림을 하나의 태그와 물건과 함께 페이스 북에 업로드 할 수있는 화합 게임을하고있는 친구. 문제는 내가 스크린 샷을 넣을 수있는 웹 서버가없고 Fb.Feeb (그림 :) 속성은 URL 만 허용한다는 것입니다.화합의 사진을 페이스 북에 업로드

나는 HTTP POST를 사용하여 그림을 사용자 이미지에 게시 한 다음 그림에서 해당 링크를 사용할 수 있다고 읽었습니다. 그러나 HTTP POST에 대해서는 아무 것도 모릅니다.

나는 FB.API()를 사용하여 어떻게 든이 작업을 수행 할 수 있다고 읽었지만 그 사실을 알 수 없었다.

모든 샘플 코드는 크게 감사하겠습니다.

내 현재 코드 :

private string _path = "file://" + System.IO.Path.Combine(Application.persistentDataPath, "Images/image.png"); 

void Start() 
    { 
     if (!FB.IsLoggedIn) 
      FB.Login("email, publish_actions, publish_stream, user_photos", LoginCallback); 
     StartCamera(); 
    } 


private void OnBragClicked() 

{ 
    FbDebug.Log("OnBragClicked"); 

//Post(); <-- dont know how 

FB.Feed(
    linkCaption: "#hashtag", 
    picture: "???", 
    linkName: "Im hashtaging!", 
    link: "https://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest") 
    ); 
} 


void TakeSnapshot() 

{ 
    _snap = new Texture2D(_webCamTexture.width, _webCamTexture.height); 
    _snap.SetPixels(_webCamTexture.GetPixels()); 
    _snap.Apply(); 

//System.IO.File.WriteAllBytes(_path, _snap.EncodeToPNG()); 
} 

답변

4

페이스 북 SDK이 결국 일어날 수 있도록하는 방법을 가지고있다. Fb.API()를 사용해야합니다.

private byte[] postcardAsBytes; 
string textMessage = "Play this great game at http://blah.com."; 
Dictionary<string, object> d = new Dictionary<string, object> 
    { 
    { "message", textMessage }, 
    { "picture", postcardAsBytes } 
    }; 
Facebook.instance.graphRequest(
     "me/photos", HTTPVerb.POST, d, yourCompletionHandler); 
// in this example using the prime31 plugin, rather than the fb sdk 

키 필드는 것 같다 ...이 라인을 따라 "라고 메시지 일반적인 용어로

private void TakeScreenshot() 
{ 
    var snap = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); 
    snap.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); 
    snap.Apply(); 
    var screenshot = snap.EncodeToPNG(); 

    var wwwForm = new WWWForm(); 
    wwwForm.AddBinaryData("image", screenshot, "barcrawling.png"); 

    FB.API("me/photos", HttpMethod.POST, LogCallback, wwwForm); 
} 

, 자막의 일종을 추가 : 이것은 나를 위해 일한 방법입니다 ". 혼란스럽게도, FB에 의해 문서화 된 "사전"필드는 작동하지 않는 것 같습니다. 그래서 처음에는 "message"를 시도하십시오.

+0

캡션/미리 정의 된 텍스트 나 설명을 추가 할 수있는 방법이 있습니까? – Imran

+0

내가 찾은 것이 아니라 미안합니다 – Reaver

+0

@Imran 수 : wwwForm.AddField ("message", "Your message here"); wwwForm.AddField ("description", "Your description here"); –