如何根据表单输入生成可共享链接

时间:2014-02-26 13:30:50

标签: php facebook forms hyperlink social-networking

所以我正在处理一个表单,该表单通过链接输出到带有自定义标题的页面。(类似于StumbleUpon)

我遇到的麻烦是能够在Facebook或其他社交媒体上分享该页面。因为目前它的链接都是相同的,无论它是什么页面。(链接是我有表单操作的页面)。

我希望输出的页面具有“可共享”链接。就像我在Facebook上粘贴该页面的链接一样,它会生成缩略图,简短描述等。

1 个答案:

答案 0 :(得分:1)

嗯,基本上,这个过程应该是这样的:

1. Take input from the form (presumabli input type=text name=url)
2. Save that $_POST[url] to the database, and assign unique identifier to it (id, hash, uuid, ...)
3. Redirect user to visit.php?hash=assigned_hash which will display the saved page based on the hash from the database

这是一种方法(在我看来更好)。另一种方法是,将表单方法更改为GET,这样您就可以获得链接

http://yoursite/url.php?url=http...

然后可以复制和粘贴哪些内容,但也可以让用户查看链接并可能更改链接以及其他内容。

让我知道你的想法