Sharing on Facebook from Android using setContentUrl()

前端 未结 1 1315
生来不讨喜
生来不讨喜 2021-01-26 11:26

I am having some trouble while trying to share content from my app into Facebook. I am using the following code to do it:

facebookButton.setOnClickListener(new V         


        
相关标签:
1条回答
  • 2021-01-26 12:27

    FadyDev, I don't know if you've already resolved your problem but this is what I do in place of deprecated codes:

    // Builds the object    
       ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                .putString("fb:app_id", my_app_ID)
                .putString("og:url", link_to_site)
                .putString("og:type", objectType)
                .putString("og:title", contentTitle)
                .putString("og:description", contentDescription)
                .putString("og:image", imageLink)
                .build();
    
    // Builds the action
            ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType(actionName)
                    .putObject(objectName, object)
                    .build();
    
    // Create the openGraphContent
            ShareOpenGraphContent openGraphContent = new ShareOpenGraphContent.Builder()
                    .setPreviewPropertyName(objectName)
                    .setAction(action)
                    .build();
    
            return openGraphContent;
    

    Look in the facebook doc for what action you want to use and there corresponding object type and required parameters.

    https://developers.facebook.com/docs/sharing/opengraph/using-actions https://developers.facebook.com/docs/reference/opengraph

    Hope this helps!

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