简体   繁体   English

在Android应用中打开Goog​​le+的图表标记

[英]Open Graph Tag for Google+ in Android application

I'm trying to post a URL from an Android application on Google+. 我正在尝试在Google+上发布Android应用中的网址。 This URL has OgTags but there are unable to fetch content, neither the title, the image or the description. 此URL具有OgTags但无法获取内容,无论是标题,图像还是描述。

Does anybody have an idea for repair it ? 有人有修理的想法吗?

Here's the code of the URL : 这是URL的代码:

<!DOCTYPE html>
<html lang="fr-FR" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="robots" content="noindex,follow"/>
<meta property="og:locale" content="fr_FR" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Test Title" />
<meta property="og:description" content="Test description" />
<meta property="og:url" content="http://www.test.com/test" />
<meta property="og:site_name" content="Test name" />
<meta property="article:published_time" content="2013-11-29T17:09:55+00:00" />
<meta property="article:modified_time" content="2014-05-21T10:05:55+00:00" />
<meta property="og:updated_time" content="2014-05-21T10:05:55+00:00" />
<meta property="og:image" content="test_content.png" />

And here's the code for builing the request : 这是构建请求的代码:

public GooglePlusHelper(Activity context) {
    mActivity = context;
    mPlusClient = new PlusClient.Builder(mActivity, this, this)
    .setActions("http://schemas.google.com/AddActivity", "http://schemas.google.com/ReviewActivity")
    .setScopes("PLUS_LOGIN") // Space separated list of scopes
    .build();
}

public void connect() {
    mPlusClient.connect();
}

public void disconnect() {
    mPlusClient.disconnect();
}

/**
 * Open Google+ to share a link
 * 
 * @param message
 * @param link
 */
public void shareUrl(String message, String link) {
    if (!Tools.hasNetworkConnection(mActivity)) {
        AlertHelper.displayInternetRequired(mActivity);
        return;
    }
    Intent shareIntent = new PlusShare.Builder(mActivity)
    .setType("text/plain")
    .setText(message)
    .getIntent();
    if (mActivity.getPackageManager().queryIntentActivities(shareIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
        mActivity.startActivityForResult(shareIntent, SHARE_REQUEST);
    } else {
        AlertHelper.displayGooglePlusRequired(mActivity, new Runnable() {

            @Override
            public void run() {
                mActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(mActivity.getString(R.string.uri_app_market) + "com.google.android.apps.plus")));
            }
        });
    }
}

And I call this with : 我称之为:

mGooglePlusHelper.shareUrl("Go share it !", "http://www.test.com/test");

Thanks 谢谢

http://www.test.com/test just does a redirect so I'm guessing that's not your actual page. http://www.test.com/test只是重定向,所以我猜这不是你的实际页面。 The page shared has to be publically accessible on the internet for Google's servers to fetch and parse it. 共享的页面必须在互联网上公开访问,以便Google的服务器获取和解析它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM