- Home /
facebook video upload using prime31
I'm struggling to do a video upload using the prime31 social networking plugin. Mike at Prime31 said it's possible using www so I've been giving it a shot as you can see below. I also have placed in this document the facebook suggested php method to upload a video. I'm having trouble merging the two together and was wondering if anybody could look at my code and maybe explain where I've gone wrong. I am able to login and get a token with the prime31 plugin. I set the facebook app with permissions that should allow video uploading but am a little confused about that. The error I get when implementing my code after getting a token is 400 bad request.
My code so far
private WWW w;
public void FBPostVideo(){
Debug.Log("in the fbpostvideo ienumerator");
var moviebytes = System.IO.File.ReadAllBytes(Application.persistentDataPath+"/screenrecording.mp4");
Debug.Log(moviebytes.Length);
WWWForm form = new WWWForm();
var video_desc="walkingthedog";
var video_title="dogwalk";
var access_token=token;
form.AddBinaryData("file", moviebytes, "myvideo");
var formurl="https://graph-video.facebook.com/me/videos?title="+video_title + "&description=" +video_desc + "&"+token;
Debug.Log(formurl);
WWW w = new WWW(formurl, form);
StartCoroutine(waitForMovie(w));
}
public IEnumerator waitForMovie(WWW w){
yield return w;
if (!String.IsNullOrEmpty(w.error))
Debug.Log(w.error);
else
Debug.Log("Finished Uploading");
}
*
*The php suggested code:
<?php
$app_id = "YOUR_APP_ID";
$app_secret = "YOUR_APP_SECRET";
$my_url = "YOUR_POST_LOGIN_URL";
$video_title = "YOUR_VIDEO_TITLE";
$video_desc = "YOUR_VIDEO_DESCRIPTION";
$code = $_REQUEST["code"];
if(empty($code)) {
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&scope=publish_stream";
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$access_token = file_get_contents($token_url);
$post_url = "https://graph-video.facebook.com/me/videos?"
. "title=" . $video_title. "&description=" . $video_desc
. "&". $access_token;
echo '<form enctype="multipart/form-data" action=" '.$post_url.' "
method="POST">';
echo 'Please choose a file:';
echo '<input name="file" type="file">';
echo '<input type="submit" value="Upload" />';
echo '</form>';
?>*
@dansav did you get it working, I'm looking for a way to share my videos in Facebook too.
Your answer
Follow this Question
Related Questions
Prime31 Facebook login failing if logged into facebook through settings 1 Answer
I cannot log into Facebook when logged in via the settings screen of iOS 0 Answers
Sharing fly through video advice 0 Answers
Facebook "Like", Prime31 (ACTUAL $400 PayPal REWARD) 3 Answers
remote_app_id does not match stored id (with different hashes) 2 Answers