Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dansav · Apr 25, 2013 at 02:14 AM · videofacebookuploadprime31

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>';
     ?>*


Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kkarunakaran · May 28, 2013 at 05:26 PM 0
Share

@dansav did you get it working, I'm looking for a way to share my videos in Facebook too.

avatar image dansav · May 30, 2013 at 07:20 PM 0
Share

no. I did not. I'm going to post on stack overflow.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges