开发者

How can I share and play an audio MP3 file in a facebook profile/

开发者 https://www.devze.com 2023-04-10 14:09 出处:网络
I need to be able to share an audio file to my wall and friend\'s wall in facebook. Additionally, I also have to play the audio when I click the image of the shared item on the user\'s profile.

I need to be able to share an audio file to my wall and friend's wall in facebook. Additionally, I also have to play the audio when I click the image of the shared item on the user's profile.

I have attempted to use the following function to share but I do not know how I can change the image ..

开发者_JS百科
function fb_share() {
    var linkVideo = "http://www.youtube.com/watch?v=nXefLc5VXsGY";
    u=linkVideo;
    t=document.title;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436'); 
}

I have also tried the API code

FB.init({
            appId  : 'appid', // application Id
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
            xfbml  : true  // parse XFBML
        });
    function publishStream(targetId, name, link, picture, source, userName,message) {
FB.ui(
        {
             method: 'feed',

                 name: name,
                 link: link,
                 picture: picture,
                 source:  source, // The URL of a media file (e.g., a SWF or video file) attached to this post
                     caption: 'Shared by '+userName,
                 actions:  {name: 'Try App', link: link},
                     message: message

            },
            function(response){
             if (response && response.post_id) {

             } else {

             }
        });
        }

but I cannot choose my friends and post to their wall. In short using this API I need to get a dialog like the first sharer..

And how can I play my audio files on the user profile?


Using the sharer URL method, Facebook looks for a series of Open Graph metatags at the top of the page you are sharing. These tags define the content and how Facebook interprets it when it's shared on a wall.

for example if you were to share a video using the JW media player on your site, you would include the following metatag types on your page:

<meta property="og:title" content="Bits on the Run introduction video"/>
<meta property="og:description" content="Bits on the Run is a clear and flexible platform 
for transcoding, managing and streaming your video online."/>
<meta property="og:image" content="http://example.com/thumbs/yYul4DRz-320.jpg" />
<meta property="og:site_name" content="http://www.mysite.com" />
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://example.com/previews/MSO47ORl-tBhZ0fIU"/>
<meta property="og:video" content="http://example.com/players/yYul4DRz-tBYU3ED4.swf" />
<meta property="og:video:height" content="245" />
<meta property="og:video:width" content="400" />
<meta property="og:video:type" content="application/x-shockwave-flash" />

Using the JW media player for example, and including the metatags you can share audio content with an image by including the og:image parameter. You are trying to share a Youtube video directly, where you do not have direct access to a page, so you cannot modify the contents of the metatags on youtube. Instead use the JW player which takes Yotube as a parameter and audio files/mp3 as well.

for more information looks here:

https://developers.facebook.com/docs/opengraph/


You can't just play stuff on another person's profile by posting. All that code makes it seem like you are creating an app - which your friend would need to install/give access to first.

Much simpler is to find a video on youtube (which it seems you're doing). You can just post it to their wall and it will automatically be playable (not play itself automatically though) from the user's wall.

This functionality is already built in to facebook. There's no need to use any code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号