网页分享功能的实现代码

<body>
<a title="转发至QQ空间" charset="400-03-8" id="s_qq"
href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=你的网站地址"
target="_blank"><img
src="http://static.youku.com/v1.0.0691/v/img/ico_Qzone.gif" /></a>
<a title="转发至人人网" charset="400-03-7" id="s_renren"
href=http://share.renren.com/share/buttonshare.do?link=你的网站地址&title=标题
target="_blank"><img
src="http://static.youku.com/v1.0.0691/v/img/ico_renren.gif" /></a>
<a title="转发至新浪微博" charset="400-03-10" id="s_sina"
href="http://v.t.sina.com.cn/share/share.php?appkey=2684493555&url=你的网站地址&title=Uid=&source=&sourceUrl="
target="_blank"><img
src="http://static.youku.com/v1.0.0691/v/img/ico_sina.gif" /></a>
<a title="分享到腾讯朋友" charset="400-03-19" id="s_pengyou"
href=http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?to=pengyou&url=你的网站地址&title=%标题
target="_blank"><img
src="http://static.youku.com/v1.0.0691/v/img/ico_pengyou.png" /></a>
<a title="推荐到豆瓣" charset="400-03-17" id="s_douban"
href=http://www.douban.com/recommend/?url=你的网站地址&title=标题
target="_blank"><img
src="http://static.youku.com/v1.0.0691/v/img/ico_dou_16x16.png" /></a> <
<a title="分享至百事渴望公社" charset="400-03-21" id="s_pepsi"
href="http://www.pepsi.cn/share.html?link=你的网站地址" target="_blank"><img
src="http://static.youku.com/v1.0.0691/v/img/ico_pepsi.jpg" /></a>


<!-- JiaThis Button BEGIN -->
<div id="ckepop">
<span class="jiathis_txt">分享到:</span> <a class="jiathis_button_weixin">微信</a>
<a href="http://www.jiathis.com/share"
class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis"
target="_blank">更多</a> <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript"
src="http://v3.jiathis.com/code/jia.js?uid=1" charset="utf-8"></script>
</div>
</body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Laravel 中实现微信分享功能,你需要完成以下步骤: 1. 注册微信开放平台账号并创建一个应用。 2. 在 Laravel 项目中安装 EasyWeChat 扩展包。可以通过 composer 进行安装:`composer require overtrue/laravel-wechat`。 3. 在 `config/app.php` 文件中的 `providers` 数组中添加服务提供者:`Overtrue\LaravelWeChat\ServiceProvider::class`。 4. 运行以下命令发布配置文件:`php artisan vendor:publish --provider="Overtrue\LaravelWeChat\ServiceProvider"`。 5. 在 `.env` 文件中配置微信相关的信息,包括 `WECHAT_APPID`、`WECHAT_SECRET`、`WECHAT_TOKEN` 和 `WECHAT_AES_KEY`。 6. 创建一个路由和控制器来处理微信分享请求,例如在 `routes/web.php` 文件中添加以下代码: ```php Route::get('/wechat/share', 'WeChatController@share'); ``` 7. 创建 `WeChatController` 控制器并在其中实现 `share()` 方法,例如: ```php <?php namespace App\Http\Controllers; use EasyWeChat\Factory; class WeChatController extends Controller { public function share() { $config = [ 'app_id' => config('wechat.appid'), 'secret' => config('wechat.secret'), 'token' => config('wechat.token'), 'aes_key' => config('wechat.aes_key') ]; $app = Factory::officialAccount($config); $jssdk = $app->jssdk; $url = request()->fullUrl(); $shareConfig = $jssdk->setUrl($url)->buildConfig(['onMenuShareTimeline', 'onMenuShareAppMessage'], false); return view('wechat.share', compact('shareConfig')); } } ``` 8. 创建一个视图来显示分享相关的页面,例如 `resources/views/wechat/share.blade.php`: ```html <!DOCTYPE html> <html> <head> <title>WeChat Share</title> <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> </head> <body> <!-- 在此处使用 $shareConfig 配置微信分享 --> </body> </html> ``` 9. 在 `share.blade.php` 视图中使用 `$shareConfig` 配置微信分享,具体使用方法可以参考 EasyWeChat 文档。 现在,当用户访问 `/wechat/share` 路径时,将会显示一个包含微信分享功能的页面。你可以根据需要自定义分享的标题、描述、链接等信息。记得在微信开放平台中配置好相关的网页授权和分享设置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值