Download the PHP package sxqibo/fast-ip without Composer

On this page you can find all versions of the php package sxqibo/fast-ip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fast-ip

根据 IP 获取 归属地

做后整理日期:2023-08-09

一、介绍

本 composer 包实现了 3 个接口,分别是

其中,太平洋 和 百度 是免费的,阿里云 是按此收费。

太平洋 请求成功率高,但是返回的信息较少;

百度 请求频繁会限流,但是返回的信息较多;

阿里云 请求成功率高,返回的信息较多,但是按次收费。

二、使用方法

1、引入

引入方式是直接使用 composer 命令引入即可

2、实例化

实例化的方式是通过工厂方式进行实例化的

该工厂通过参数获取对应的具体实现类,目前支持的参数有:

参数也可以为空,为空的情况下,相当于传入 online

如果没有找到传入的类,则默认返回 online 的实例

3、调用方法

调用方法有两种方式,一种方式调用实例方法,另外一种方法是调用静态方法

(1)调用实例方法

调用实例方法,需要通过工厂实例化后调用 getIpCity 方法得到 归属地

(2)调用静态方法

直接调用实现类下的静态方法即可

注意:目前静态方法只有 IpCityForOnline 实现了,其他的都没有实现

4、返回结果

返回结果是数组,数组分为两部分:

  1. 一部分是 格式化 后的通用数据,其中保存了 省、市、县(区)
  2. 一部分是接口返回的原始数据,原始数据字段多少各不相同,不太方便实用

其中 格式化 后的部分在 'data' 中,原始数据在 'org'

(1)举例

a、阿里云
b、百度
c、太平洋

三、备注

下面是各个接口返回的数据的格式

1、阿里云

2、百度

3、太平洋

四、报错处理

若出现错误如下: Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/… in xxx.php

其原因是由于本地的CURL的SSL证书太旧了,导致不识别此证书。

解决方法

  1. http://curl.haxx.se/ca/cacert.pem 下载一个最新的证书。然后保存到一个任意目录。
  2. 然后把catr.pem放到php的bin目录下,然后编辑php.ini,用记事本或者notepad++打开 php.ini文件,大概在1932行。 去掉curl.cainfo前面的注释“;”,然后在后面写上cacert.pem证书的完整路径及文件名,我的如下:
  3. curl.cainfo = /Applications/EasySrv/software/php/php-8.2/bin/cacert.pem

All versions of fast-ip with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version >=6.0
ext-mbstring Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sxqibo/fast-ip contains the following files

Loading the files please wait ....