分享Open Graph- Facebook分享

时间:2018-11-27 21:54:05

标签: facebook-share share-open-graph

我使用此代码分享了地点,但没有响应 有经验的人可以帮忙吗?

    ShareButton shareButton = (ShareButton)findViewById(R.id.fb_share_button);
         SharePhoto photo = new SharePhoto.Builder()
                    .setImageUrl(Uri.parse(img))
                    .setUserGenerated(true)
                    .build();

//Create an Object
       ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                .putString("og:type", "place")
                .putString("og:title", "title")
                .putPhoto("og:image", photo)
                .putString("og:description", "description")
                .putString("place:location:latitude", Double.toString(lat))
                .putString("place:location:longitude", Double.toString(lng))
                .build();

// Create an action
        ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                .setActionType("news.publishes")
                .putObject("place", object)
                .build();

//Create an content
        ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
                .setPreviewPropertyName("place")
                .setAction(action)
                .build();



        shareButton.setShareContent(content);
        ///////////////////////
        TextView shareFB = (TextView) findViewById(R.id.fb_share_button_custom);

        // Set a click listener on the custom facebook share button
        shareFB.setOnClickListener(new View.OnClickListener() {

            // The code in this method will be executed when the Share  on Facebook custom button is clicked on
            @Override
            public void onClick(View view) {
                shareButton.performClick();

            }
        });



    }

我使用了这段代码,但是在og:type中使用该位置时出现了问题。 我尝试使用其他类型,但是在选择地点类型时会出现问题。

0 个答案:

没有答案