视频上传与图形API从用户的桌面 [英] Video upload with Graph API from user's desktop

查看:201
本文介绍了视频上传与图形API从用户的桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过图形API上传本地视频到Facebook。
下面是从Facebook的例子:
http://developers.facebook.com/blog/post/493/
这工作不错,我也得到来自提交后JSON响应。
我怎样才能获得输入反应ID,用于,例如Javascript或直接作为我的服务器上的一个GET参数?
我不想上传的公共accessable服务器上的视频,然后通过卷曲或类似的东西重定向视频上传到Facebook。

i am trying to upload a local video to Facebook through the Graph API. Here is an example from Facebook: http://developers.facebook.com/blog/post/493/ That works nice, and i get an JSON response after submitting the from. How can I get the respone ID, for use in, e.g. Javascript or directly as an GET-parameter on my server? I don't want to upload the video on an public accessable server and then redirect the video upload to Facebook by using curl or something like that.

有没有人一个想法或如何我能得到这个工作?一个例子

Has anyone an idea or an example of how i can get this to work?

编辑:

下面是我使用的示例:

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

从该页面摘自: http://developers.facebook.com/blog/post/ 493 /

这是整个响应我从形式得到(JSON响应):

This is the whole response i get from the form (JSON response):

{
    "id": "xxxxx19208xxxxx"
}

的问题是,JSON响应是内嵌在页面中。
我认为在表单的目标设定为一个内联iframe中,但随后我将无法访问JSON code。

The problem is that the JSON response is inline in the page. I thought to set a target in the form to an inline iframe but then i will not be able to access the JSON code.

推荐答案

我在这里创造一个教程花费在Facebook上的照片/视频上传的时间最多:的http://www.epixseo.com/index.php/facebook-php-3-3-1-and-javascript-sdk-graph-api-tutorial/

I created a tutorial here spending the most time on Facebook photo/video upload: http://www.epixseo.com/index.php/facebook-php-3-3-1-and-javascript-sdk-graph-api-tutorial/

这是照片和视频将检测MIME类型的多选载。当用户上传照片/视频,脚本由FB ID创建一个临时文件夹,并在上载被发送到Facebook的它会删除整个temp文件夹不留隐藏文件在服务器上。

It is a multiselect upload for photos and videos that will detect MIME type. When a user uploads a photo/video, the script creates a temp folder by fb id and once the upload is sent to Facebook it deletes the entire temp folder leaving no files behind on the server.

另外,你可以用这个方法: http://developers.facebook.com/blog /后/ 608 /

Alternatively, you can use this method: http://developers.facebook.com/blog/post/608/

这篇关于视频上传与图形API从用户的桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆