简体   繁体   English

Facebook PHP API:通过@ [PAGE_ID]提及页面

[英]Facebook PHP API: mentioning page through @[PAGE_ID]

I guess I have read all past posts about the argument, but I was wondering if something has changed on topic. 我想我已经读过所有有关该论点的文章,但是我想知道关于这个话题是否有所改变。

Is it now possible to mention a page inside a message text using Facebook PHP SDK? 现在可以使用Facebook PHP SDK在消息文本中提及页面吗? Something like this: 像这样:

$post_params = array(
   'access_token' => PAGE_TOKEN,
   'message' => 'This is a message tagged to @[PAGE_ID]
);
$postStream = $this->facebook->api("/" . PAGE_ID . "/feed", 'post', $post_params);

I am referring to this page: https://developers.facebook.com/docs/opengraph/guides/tagging/ 我指的是此页面: https : //developers.facebook.com/docs/opengraph/guides/tagging/

Actually, so far, I solved the problem the following way: 实际上,到目前为止,我已通过以下方式解决了该问题:

1) "Normalize" the page name through a regex replacement of possible "facebook related" uri 1)通过正则表达式替换可能的“与Facebook相关的” uri来“标准化”页面名称

$replacePattern = '((https|http)?(:\/\/)?(www\.)?(facebook\.com)?(\/)?)';
$page_name = preg_replace($replacePattern, '', $page_name);
$page_name = 'https://www.facebook.com/' . $page_name;

2) Make a call to Facebook API using the "normalized" uri: 2)使用“规范化” uri调用Facebook API:

$fql = "SELECT id, name FROM profile WHERE id in (SELECT id FROM object_url WHERE url='" . $page_name . "')";
    $param = array(
        'method'        => 'fql.query',
        'query'         => $fql,
        'callback'      => ''
    );
    $response = $facebook->api($param);

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

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