(自写程序)京东“玩一玩”票数与兑换红包库存等API源码分享

 2024-08-05  阅读 297  评论 0  点赞 0

摘要:玩Docker青龙面板的应该都懂,自己写的小玩意,希望能帮到你,发挥自己的想象可以继续开发一下,源码如下:

玩Docker青龙面板的应该都懂,自己写的小玩意,希望能帮到你,发挥自己的想象可以继续开发一下,源码如下:

  
<?php
/*================================================
作者信息: 伟航工作室 [QQ:327954269] [www.weihangapi.cn]
=================================================*/
function wanyiwan($cookie) {
    $url = "http://api.m.jd.com/client.action?functionId=wanyiwan_exchange_page&appid=signed_wh5&body=" . urlencode(json_encode(['version' => 2])) . "&networkType=wifi&client=ios&clientVersion=" . getClientVersion() . "&t=" . time();

    $headers = [
        "Cookie: $cookie",
        "Content-Type: application/x-www-form-urlencoded",
        "Origin: https://pro.m.jd.com",
        "Referer: https://pro.m.jd.com/",
        "User-Agent: " . getUserAgent()
    ];

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);

    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }

    curl_close($ch);

    // 处理返回的响应
    // 例如,调试输出
    var_dump($response);
}

function getUserAgent() {
    // 这里是返回用户代理字符串的示例函数
    return "Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148";
}

function getClientVersion() {
    // 从用户代理字符串中提取客户端版本的示例函数
    $userAgent = getUserAgent();
    $parts = explode(";", $userAgent);
    return isset($parts[2]) ? trim($parts[2]) : "";
}

// 示例调用
$cookie = "pt_key=xxx;pt_pin=xxx;";
wanyiwan($cookie);

可以不加cookie返回json为:

{"code":0,"data":{"bizCode":0,"bizMsg":"调用成功","result":{"hotExchanges":[],"isLogin":true,"moreExchanges":[{"assignmentId":"3UvXZQz3U5FuBLdvLhwuW6YutVTY","batchId":"1062929842","discount":"2.0","exchangeScore":200,"exchangeStatus":1,"hasStock":true,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/197209/6/44169/31824/664490c0F4d490f6d/54c5ca5d43c2ac65.png","rewardName":"2元优惠券","rewardType":2},{"assignmentId":"2VLdkDgARfe34h18XeMeXEQJxYLS","exchangeScore":120,"exchangeStatus":2,"hasStock":true,"hbId":"871940","hbValue":"1.00","hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/226679/39/18416/34454/6662ccf8F9a49b9f7/8a605327d161c0a6.png","rewardName":"1元红包","rewardType":1},{"assignmentId":"36hVXcH32ZYnJP385vtqVgUmG5jz","beanPrize":"0.80","exchangeScore":120,"exchangeStatus":4,"hasStock":false,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/14699/39/22435/13224/66ac7520Ff9089bdf/f92d2d1c1339a0c1.png","rewardName":"80京豆","rewardType":3},{"assignmentId":"2NbbfKfgDt3zeCLa3t3mioL9ZbK6","beanPrize":"1.20","exchangeScore":180,"exchangeStatus":4,"hasStock":false,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/75173/40/27749/13224/66a9a62eF1b49fd43/ec72483a5122617d.png","rewardName":"120京豆","rewardType":3},{"assignmentId":"2HSA318NHrMLQWNwFxoRioaQU9ad","beanPrize":"3.00","exchangeScore":450,"exchangeStatus":4,"hasStock":false,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/232926/1/24408/13224/66a79821F9af9369d/831f0abf932c579e.png","rewardName":"300京豆","rewardType":3},{"assignmentId":"3g9bumoahLCU9Hu97eKvQmLFXb62","beanPrize":"6.00","exchangeScore":900,"exchangeStatus":4,"hasStock":false,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/39403/13/22691/13224/669e2f3eFe7a31988/41685eb13b57d2c0.png","rewardName":"600京豆","rewardType":3},{"assignmentId":"4RuCPvkKa883gV7SPnpuBnaamPFd","beanPrize":"8.00","exchangeScore":1200,"exchangeStatus":4,"hasStock":false,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/237416/5/20762/13224/66a9a639F0b870d15/cebd60379b254777.png","rewardName":"800京豆","rewardType":3},{"assignmentId":"2HoJxYHuTLQgsHiVFpBceGT8oPAB","beanPrize":"50.00","exchangeScore":7500,"exchangeStatus":4,"hasStock":false,"hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/248961/33/15686/13224/669e2ec2F9019ea9e/eba7efd3a8148c18.png","rewardName":"5000京豆","rewardType":3},{"assignmentId":"24TStF6gWS7nCYhdowJ5SmH43f1z","exchangeScore":10560,"exchangeStatus":4,"hasStock":false,"hbId":"892547","hbValue":"88.00","hot":false,"rewardImg":"https://m.360buyimg.com/babel/jfs/t1/61054/40/26396/13773/669f79ebFc10fa15e/7d6e612ba6434d20.png","rewardName":"88元红包","rewardType":1}],"rule":"https://m12.360buyimg.com/dripworks/jfs/t1/234377/21/24254/4680720/66a76d40Ffca7b3b0/269e6f9b2585469c.jpg","score":2584}},"message":"调用成功"}"
标签:自写程序php

发表评论:

管理员

承接各种程序开发,外贸网站代运营,外贸网站建设等项目
  • 内容185
  • 积分66666
  • 金币66666

Copyright © 2024 LS'Blog-保定PHP程序员老宋个人博客 Inc. 保留所有权利。 Powered by LS'blog 3.0.3

页面耗时0.0239秒, 内存占用1.89 MB, 访问数据库23次

冀ICP备19034377号