我在PHP中有一个生成的链接,它接受用户的ID,并将其放在推荐链接的末尾,以跟踪谁推荐谁使用推荐系统。通过php的链接示例:
http://example.com/index.php?page=act/reg&inv=$arrusr[0]我正在尝试为facebook,twitter,email创建一个分享按钮,甚至用bitly api添加一个shortener --但是我总是遇到同样的问题……它不会更新用户ID,而是直接按原样发送URL。
很明显我在做一件很愚蠢的事。任何帮助都是非常感谢的。
如何共享链接:
<a class='btn btn-tw' href='https://twitter.com/home?status=http://example.com/test/index.php?page=act/reg&inv=$arrusr[0]'><i class='fa fa-2x fa-twitter twcolor'></i></a>链接按原样工作。如果我只想创建一个简单的链接,它会给我类似这样的例子(当然这取决于用户):
http://example.com/index.php?page=act/reg&inv=43为什么,当我使用facebook、twitter或bitly api分享链接时,它拒绝在url的末尾填充用户id?
非常感谢您的帮助!
编辑(不起作用的完整php代码)
<?php
echo "
<div class='row'><!-- start of row text -->
<div class='col-md-4'>
<center><img src='image/logo.png' alt='Logo' class='img-circle img-responsive logo-size' style='max-height:275px;'></center>
<div id='DateCountdown' class='img-responsive' data-date='2014-11-01 04:05:00'></div><br />
</div>
<div class='col-md-8 welcome-bar'>
<img src='image/thankyoubanner.png' alt='Thank you for signing up' class='img-responsive'>
<h2>Invite friends and<br />win more prizes!</h2>
<p align='center'>Share this unique link via email, facebook or twitter and win more prizes as each friend signs up.</p>
<center><form role='form'>
<input class='form-control' id='focusedInput' type='text' value='http://example.com/index.php?page=act/reg&inv=$arrusr[0]' style='max-width:375px;text-align:center;'>
</form></center>
<a class='btn btn-fb' href=http://www.facebook.com/sharer/sharer.php?u=http://example.com/index.php?page=act/reg&inv=$arrusr[0]'><i class='fa fa-2x fa-facebook fbcolor'></i></a>
<a class='btn btn-em' data-toggle='modal' data-target='#subscribe'><i class='fa fa-2x fa-envelope-o emcolor'></i></a>
<a class='btn btn-tw' href='https://twitter.com/home?status=http://example.com/index.php?page=act/reg&inv=$arrusr[0]'><i class='fa fa-2x fa-twitter twcolor'></i></a>
</div>
</div><!-- end of row countdown -->
";
?>这个php是一个小盒子,它可以正确地生成复制代码(使用引导程序框架),然后生成当前未运行的共享链接。(忽略电子邮件链接,因为这是正常工作的模式)
发布于 2014-10-28 03:38:56
您需要使用echo显示id,现在您只是将其显示为静态html,没有其他内容,请将其修改为
<a class='btn btn-tw' href='https://twitter.com/home?status=http://example.com/test/index.php?page=act/reg&inv=<?php echo $arrusr[0]; ?>'><i class='fa fa-2x fa-twitter twcolor'></i></a>发布于 2014-10-28 03:39:36
您可能希望对该值执行echo操作:
<a class='btn btn-tw' href='https://twitter.com/home?status=http://example.com/test/index.php?page=act/reg&inv=<?php echo $arrusr[0]; ?>'><i class='fa fa-2x fa-twitter twcolor'></i></a>更新:
尽管它应该可以在您的更新中正常工作,但请尝试:
<?php
echo "
<div class='row'><!-- start of row text -->
<div class='col-md-4'>
<center><img src='image/logo.png' alt='Logo' class='img-circle img-responsive logo-size' style='max-height:275px;'></center>
<div id='DateCountdown' class='img-responsive' data-date='2014-11-01 04:05:00'></div><br />
</div>
<div class='col-md-8 welcome-bar'>
<img src='image/thankyoubanner.png' alt='Thank you for signing up' class='img-responsive'>
<h2>Invite friends and<br />win more prizes!</h2>
<p align='center'>Share this unique link via email, facebook or twitter and win more prizes as each friend signs up.</p>
<center><form role='form'>
<input class='form-control' id='focusedInput' type='text' value='http://example.com/index.php?page=act/reg&inv=".$arrusr[0]."' style='max-width:375px;text-align:center;'>
</form></center>
<a class='btn btn-fb' href=http://www.facebook.com/sharer/sharer.php?u=http://example.com/index.php?page=act/reg&inv=".$arrusr[0]."'><i class='fa fa-2x fa-facebook fbcolor'></i></a>
<a class='btn btn-em' data-toggle='modal' data-target='#subscribe'><i class='fa fa-2x fa-envelope-o emcolor'></i></a>
<a class='btn btn-tw' href='https://twitter.com/home?status=http://example.com/index.php?page=act/reg&inv=".$arrusr[0]."'><i class='fa fa-2x fa-twitter twcolor'></i></a>
</div>
</div><!-- end of row countdown -->
";
?>通过将值与字符串连接。
https://stackoverflow.com/questions/26595470
复制相似问题