以下是用PHP编写的微信分享和分享微信好友的代码示例:
分享微信朋友圈代码:
<?php
// 微信AppID和AppSecret
$appId = 'your_app_id';
$appSecret = 'your_app_secret';
// 获取当前访问的URL
$url = $_SERVER['REQUEST_URI'];
// 获取当前操作的用户信息(这里假设已经获取到用户信息)
$user = [
'name' => '用户名',
'avatar' => '用户头像URL',
// 其他用户信息...
];
// 构造请求微信接口的URL
$wxApiUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$appId}&redirect_uri={$url}&response_type=code&scope=snsapi_publish&state={$state}";
?>
<a href="<?php echo $wxApiUrl; ?>" target="_blank">分享到微信朋友圈</a>分享微信好友代码:
<?php
// 微信AppID和AppSecret
$appId = 'your_app_id';
$appSecret = 'your_app_secret';
// 获取当前操作的用户信息(这里假设已经获取到用户信息)
$user = [
'name' => '用户名',
'avatar' => '用户头像URL',
// 其他用户信息...
];
// 构造请求微信接口的URL
$wxApiUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$appId}&redirect_uri={$url}&response_type=code&scope=snsapi_contact&state={$state}";
?>
<a href="<?php echo $wxApiUrl; ?>" target="_blank">分享给微信好友</a>
评论 (0)