使用不考虑OG元标记的API发布Facebook POST

时间:2016-02-11 06:20:02

标签: facebook facebook-graph-api facebook-opengraph publish metatag

在我的网站上我保存了新页面&使用this facebook link自动在我的脸书页面中发布该页面,但在发布后如果我想正常分享这篇文章并把网址我没有得到任何标题或图片或..当我去facebook Open Graph Object Debugger并输入该URL我意识到它没有读取og标签,但如果我点击"获取新的刮擦信息"它正确地从og标签中获取信息。问题是什么?如何解决?

下面是我使用的PHP代码函数:

function facebook_post($fb_data) {
    $config = array('appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET);
    $fb = new Facebook($config);
    $fb->setAccessToken(FACEBOOK_ACCESS_TOKEN);
    $post_access_token = FACEBOOK_ACCESS_TOKEN;
    $page_info = $fb->api("/" . FACEBOOK_PAGE_ID . "/?fields=access_token", 'GET', array('access_token' => FACEBOOK_ACCESS_TOKEN));
    $post_access_token = $page_info['access_token'];
    //
    $params = array(
        "access_token" => $post_access_token
        //, "message" => $fb_data['facebook_message']
        , "link" => $fb_data['facebook_url']
        , "picture" => $fb_data['facebook_image']
        , "name" => $fb_data['facebook_title']
        //, "caption" => $fb_data['facebook_caption']
        , "description" => ($fb_data['facebook_description'] ? $fb_data['facebook_description'] : '')
        //, "published" => true
    );
    // post to Facebook : https://developers.facebook.com/docs/reference/php/facebook-api/
    try {
        $ret = $fb->api('/me/feed', 'POST', $params);
//        $post_id = $ret['id'];
        return true;
    } catch (Exception $e) {
        return false;
    }
}

感谢。

0 个答案:

没有答案