如何使用Facebook图形API上传视频 [英] How to upload video with Facebook graph API
问题描述
我一直在努力几个星期,以了解如何使用图形API上传视频。我已经经历了所有的文档,我只是不明白我必须做什么,以获取正确的答案从图表api之前,我写的代码。我已经包含了一张图片。
I've been struggling for weeks to get figure out how to upload video using the graph api. I've gone through all the documentation and i just don't understand what i must do to get a correct response from the graph api before i write the code. I've included an image.
有人可以像孩子一样告诉我,我必须准备好什么?
Can someone just tell me like a child what I must put in exactly?
推荐答案
了解如何使用图形API与c#进行统一。
Figured out how to use graph api with c# for unity.
您可以发表评论并发布视频。
给出的URL只是一个可用的开放视频,如果需要,选择自己的,或者如果将来不可用。
you can post a comment and post a video. the url given is just an open video that was available, choose your own if you want, or if it becomes unavailable in the future.
享受! / p>
enjoy!
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using Facebook.Unity;
using Facebook.MiniJSON;
public class FBVideoPost : MonoBehaviour {
// Use this for initialization
void Start () {
// this is to post string
postStatus ();
//this is to post video
this.StartCoroutine(this.StartVideoUpload());
}
void postStatus()
{
var formdata = new Dictionary<string, string>();
formdata.Add ("message", "This is my third post!");
FB.API("/me/feed", HttpMethod.POST, delegate (IGraphResult callback){
Debug.Log ("This is a test!");
},formdata);
}
private IEnumerator StartVideoUpload()
{
yield return new WaitForEndOfFrame();
WWW www = new WWW("http://techslides.com/demos/sample-videos/small.mp4");
while(!www.isDone) {
yield return null;
Debug.Log("progress : "+www.progress);
}
Debug.Log("size : "+www.size);
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("file", www.bytes, "Video.MOV","multipart/form-data");
wwwForm.AddField("title", "Hello World");
wwwForm.AddField("description", "How you doing?");
FB.API("me/videos", HttpMethod.POST, UploadFinish, wwwForm);
}
private void UploadFinish(IGraphResult result) {
Debug.Log("result : "+result.ToString()+" , error : "+result.Error);
}
}
这篇关于如何使用Facebook图形API上传视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!