冰豆网

分享网络精彩
bingdou.com.cn

php生成微信短网址

时间:2020-07-11加入收藏

function get_short($longUrl, $accessToken)
{
    $url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=" . $accessToken;
    $header[] = "Content-Type: application/json";

    $postData = "{\"action\": \"long2short\", \"long_url\": \"$longUrl\"}";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

打 赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

TGA: php 技巧

分享到:


官方微信二维码冰豆网官方微信公众号