Posting an embedded YouTube link using the Facebook sdk

喜你入骨 提交于 2019-12-30 07:30:33

问题


When you share a YouTube link on FB with intent it automatically embeds the YouTube player into your wall and it look like this

but... when I try to post the same video using FB sdk, HelloFacebookSampleActivity => postStatusUpdate() mathood.

 public void postStatusUpdate() {
        if (user != null && hasPublishPermission()) {
            final String message ;

                message = ( user.getFirstName()+" "+ getString( R.string.status_update_link)+ " " +video_id + " " + getString(R.string.google_play_link));


            Request request = Request
                    .newStatusUpdateRequest(Session.getActiveSession(), message, new Request.Callback() {
                        @Override
                        public void onCompleted(Response response) {
                            showPublishResult(message, response.getGraphObject(), response.getError());
                        }
                    });
            request.executeAsync();
        } else {
            pendingAction = PendingAction.POST_STATUS_UPDATE;
        }
    }

it look like this

so I find this link that order to change the link format from http://www.youtube.com/watch?v=<code> to http://www.youtube.com/e/<code> or to add &autoplay=1 after the <code>

but it doesnt work... I googled "facebook android embedded link youtube" but find nothing about this issue, need help

How I posting an embedded YouTube link (like pic 1 ) using the Facebook sdk ?

UPDATE :

I convert my code, now I'm using Publish to Feed code. but the problem not solved

I try to post by source like facebook mansion , but it doesnt work...

  postParams.putString("name", "Facebook SDK for Android");
            postParams.putString("caption", "Build great social apps and get more installs.");
            postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
            postParams.putString("source","http://www.youtube.com/e/2raioEC7Hms");

回答1:


solved : using tutorial Publish to Feed , using post

 postParams.putString("message", "Link to YouTube");
        postParams.putString("link", "http://www.youtube.com/watch?v=3aICB2mUu2k");
        postParams.putString("source", "http://www.youtube.com/v/3aICB2mUu2k");
        postParams.putString("picture","http://img.youtube.com/vi/3aICB2mUu2k/0.jpg");


来源:https://stackoverflow.com/questions/17202305/posting-an-embedded-youtube-link-using-the-facebook-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!