GithubHelp home page GithubHelp logo

long2short's Introduction

long2short

一个轻量的可以生成微信短链接的接口程序

1.克隆项目到本地

git clone https://github.com/y449329998/long2short.git

2.用 short_url.sql 文件导入数据结构

3.配置 inc.php 文件

<?php
$config=[
    //数据库
    'db'=>[
        'database_type' => 'mysql', //数据库类型mysql
        'database_name' => 'shorturl',//数据库名
        'server' => '127.0.0.1',//数据库地址
        'username' => 'root',//数据库用户名
        'password' => 'root',//数据库密码
        'charset'=>'utf8',//编码
        'prefix'=>'short_'//前缀
    ],
    //获取token的微信公众号
    'wechat'=>[
        'appid'=>'wx092572556238',//微信公众号appid
        'secret'=>'fsdfgsdggfgfgsg',//微信公众号密钥
    ],
   
];

define('CONF', $config);

4.网站根目录设置为public目录

5.生产短链

5.1 get请求

http://localhost/?url=http://www.baidu.com

5.2 得到数据

{
    "error": 0,   //0,成功,1失败,2 缺少url参数
    "short_url": "https://w.url.cn/s/AAAskQk", //生产的短链
    "msg":"生产短链失败" //当error不为0是返回改字段
}

6.常见的问题

1.请查看配置未见微信公众号的appid 和 secret 是否正确
2.微信最新正常一个公众号每月最多生产10个域名下的短链,10个以后的域名会失效

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.