【问题标题】:How to add link in tweet如何在推文中添加链接
【发布时间】:2014-03-16 23:58:19
【问题描述】:

我正在使用 cakephp 推特插件。我想要做什么,我需要在推文中添加页面参考 URL。

目前我添加了推文,它将链接显示为这样的文本

In which year of First World War Germany declared war on Russia and France?<a href="xyz.com">click here</a>

但我需要推文中click here 的链接。

我该怎么做

我的推文代码是这样的

public function updateStatus($status, $options = array()) {
        if ($status != null || $status != '') {
            $body = Set::merge(array(
                'status' => $status
                ), $options);

            return json_decode($this->apiRequest('post', $this->endPoint('statuses/update'), $body), true);
        }
    }

【问题讨论】:

    标签: cakephp twitter


    【解决方案1】:

    如果我理解得很好,您需要将引用链接的 HTML 代码替换为 URL 本身,因为 Twitter 只接受纯文本,对吧?

    updateStatus里面试试这个:

    $status = preg_replace('#<a(.*?)href="(.*?)"(.*?)>(.*?)</a>#', '\\2', $status);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 2020-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      相关资源
      最近更新 更多