WordPress 和 Tiny Url 中的 Twitter 状态

发布于 2024-11-15 07:29:52 字数 354 浏览 8 评论 0原文

我有一个 WordPress 网站。我在每个帖子下面都有一个 Twitter 按钮。我想要的是,当用户点击它时,它应该将他们的 Twitter 状态更新为以下内容:

the_title().urlencode(get_permalink()) [首先是用户单击 Twitter 按钮的帖子标题,然后是帖子的 url]

我的问题是 urlencode(get_permalink()) 的输出非常大,并且在 Twitter 状态中它仅显示纯文本不是预期的超链接。我在某个地方读到过有关小网址的内容。但是应该使用什么代码来将我的 url 传递给tiny url 并获取它的缩短版本,以便超链接在我的 Twitter 状态中处于活动状态。

提前致谢!

I have a wordpress site. I have a twitter button below every post. What I want is that when a user clicks on it, it should update their twitter status to the following:

the_title().urlencode(get_permalink())
[first the title of the post on which the user clicked the twitter button followed by the url of the post]

mow my problem is that the output from urlencode(get_permalink()) is very large and in the twitter status it displays just plain text not the hyperlink as is expected. Somewhere i read about tiny url. But what should be the code to pass my url to tiny url and get the shortened version of it so that the hyperlink is active in my twitter status.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-11-22 07:29:52

我找到了解决方案。感谢您花时间查看此内容。考虑发布答案以防万一其他人遇到类似的情况

function get_tiny_url($url) { 
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,'tinyurl.com/api-create.php?url='.$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

I found the solution. Thanks if you spent time to view this. Thought to post the answer just in case anyone else faces similar situation

function get_tiny_url($url) { 
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,'tinyurl.com/api-create.php?url='.$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文