Graph API post of video is not playable

前端 未结 2 495
心在旅途
心在旅途 2021-02-06 16:43

I have an application that posts music videos from YouTube to a Facebook user\'s wall. The post on Facebook would have this embed video be playable from Facebook. Recently it st

相关标签:
2条回答
  • 2021-02-06 17:18

    Normally to share YouTube videos to Facebook pages you only need message, link, source, picture parameters. Even you can also skip the source, picture parameters if you wish to. Thats is if you are using FacebookC#SDK to share video to Facebook all you need is following code

     var fb = new Facebook.FacebookClient(yourPageAccessToken); 
     argList["message"] = message;
     argList["link"] = "http://www.youtube.com/watch?v=" + specialOffer.YoutubeId;
     argList["source"] = "http://www.youtube.com/v/" + specialOffer.YoutubeId;
     argList["picture"] = "http://img.youtube.com/vi/" + specialOffer.YoutubeId + "/0.jpg";
     fb.Post("feed", argList);
    

    or

     var fb = new Facebook.FacebookClient(yourPageAccessToken); 
     argList["message"] = message;
     argList["link"] = "http://www.youtube.com/watch?v=" + specialOffer.YoutubeId;
     fb.Post("feed", argList);
    
    0 讨论(0)
  • 2021-02-06 17:30

    Generalized Workaround

    I generalized the answer to this similar question: posting a swf in facebook feed through facebook api. I created a page that takes two parameters and generates the necessary meta tags. Facebook accepts the link, the user is correctly redirected, and you don't need a separate page for each posted video.

    1. url - the final URL
    2. id - the id of the youtube or embedded video

    I successfully made numerous embedded posts in which the link was not associated with the video.

    Example Post

    message = Post message
    description = Post description if needed.
    name = Post name
    caption = Post caption
    link = http://vbcopper.com/jsuar/so/fbembedvideo.php?url=stackoverflow.com&id=QGAJokcwBXI
    source = http://www.youtube.com/e/QGAJokcwBXI
    picture = http://img.youtube.com/vi/QGAJokcwBXI/0.jpg
    

    PHP

    <?php
     $id =  $_GET["id"];
     $url =  $_GET["url"];
    
     if ( isset($url) ) {
    echo <<< EOT
    <html>
    <head>
        <title>$url</title>
        <meta property="og:title" content="Page Title" />
        <meta property="og:type" content="website"/>
        <meta property="og:description" content="Content for Description" />
        <meta property="og:image" content="http://i2.ytimg.com/vi/$id/mqdefault.jpg" />
        <meta property="og:site_name" content="Content for caption"/>
        <meta property="og:video" content="http://www.youtube.com/v/$id?version=3&autohide=1">
        <meta property="og:video:type" content="application/x-shockwave-flash">
        <meta property="og:video:width" content="640">
        <meta property="og:video:height" content="360">
        <META http-equiv="refresh" content="1;URL=http://$url">
    
    </head>
    <body>
    </body>
    </html>
    EOT;
    } else {
        echo "Nothing here...";
    }
    ?>
    

    Findings

    I was able to successfully replicate your issue. I could find no work around.

    This has been submitted as a bug to Facebook but deemed low priority.

    Bugs: Posting video to feed with link attribute doesn't embed the source https://developers.facebook.com/bugs/502967809730190?browse=search_5074a2e48fd360934230075

    0 讨论(0)
提交回复
热议问题