2012-07-20 52 views
0

我使用以下代碼成功上傳視頻,但上傳後顯示一些ID頁面。任何人都可以幫助如何成功上傳視頻後將頁面重定向到我想要的位置。https://graph-video.facebook.com/上傳後重定向

在此先感謝。

$app_id = "YOUR_APP_ID"; 
$app_secret = "YOUR_APP_SECRET"; 
$my_url = "YOUR_POST_LOGIN_URL"; 
$video_title = "TITLE FOR THE VIDEO"; 
$video_desc = "DESCRIPTION FOR THE VIDEO"; 
$page_id = "YOUR_PAGE_ID"; 

$code = $_REQUEST["code"]; 

echo '<html><body>'; 

if(empty($code)) { 
    // Get permission from the user to publish to their page. 
    $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
     . $app_id . "&redirect_uri=" . urlencode($my_url) 
     . "&scope=publish_stream,manage_pages"; 
    echo('<script>top.location.href="' . $dialog_url . '";</script>'); 
} else { 

    $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); 

    $accounts_url = "https://graph.facebook.com/me/accounts?" . $access_token; 
    $response = file_get_contents($accounts_url); 

    $resp_obj = json_decode($response,true); 
    $accounts = $resp_obj['data']; 

    foreach($accounts as $account) { 
     if($account['id'] == $page_id) { 
      $access_token = $account['access_token']; 
      break; 
     } 
    } 

    $post_url = "https://graph-video.facebook.com/" . $page_id . "/videos?" 
     . "title=" . $video_title. "&description=" . $video_desc 
     . "&access_token=". $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>"; 
} 

回答

0

你將不得不作出的視頻上傳到Facebook發生在您的服務器端,而不是你的訪問者的瀏覽器,這樣你就可以趕上輸出和發送遊客瀏覽器到正確的地方。

您的用戶將首先將您的文件上傳到您的服務器上,然後您可以使用curl將視頻發送到Facebook,完成後您可以重定向用戶。

實例

  1. Facebook的圖形API視頻對象:http://developers.facebook.com/docs/reference/api/video/
  2. 命令行卷曲的例子:http://facebook.stackoverflow.com/questions/5227607/posting-an-embedded-video-link-using-the-facebook-graph-api
  3. 實施例與Facebook PHP API:http://facebook.stackoverflow.com/questions/9018213/video-post-on-timeline-not-playing-inline
+0

u能共享某些編碼從哪裏可以獲得幫助的鏈接 – user1537939 2012-07-30 14:01:07

+0

添加了一些鏈接,我希望那些幫助。 – complex857 2012-07-30 14:05:56