定制 ihexiang/requests 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ihexiang/requests

Composer 安装命令:

composer require ihexiang/requests

包简介

PHP Requests 支持 GET、POST、PUT、PATCH、DELETE、HEAD、OPTIONS 等请求

README 文档

README

介绍

PHP Requests 支持 GET、POST、PUT、PATCH、DELETE、HEAD、OPTIONS 等方法

运行环境

  • PHP版本 ( >= 5.4 )
  • composer

安装

composer require ihexiang/requests v1.0.1

支持的方法

响应 Response

  • 每一个请求都返回一个响应对象 response

  • 成员属性

    • header 响应头信息
    • http_code HTTP code 码
    • body 响应内容体
    • erron 错误码
    • error 错误消息
  • 成员方法

    • content() 获取文本类型的 响应内容
    • toArray(dataType) 获取数组类型的 响应内容

示例

<?php
use iHexiang\Requests\Requests;

    //1.简单示例
    echo Requests::get('https://xxx.example/test.api');


    //2.返回响应示例
    $response = Requests::get('https://xxx.example/test.api');
    if(!$response->http_code){
        echo $response->error;
    }else{

        //注:以下2种效果是一样的
        echo $response;
        echo $response->content();

        //打印数组
        //注:接口必须返回 json 或 xml 格式数据
        //var_dump($response->toArray('json'));
        //var_dump($response->toArray('xml'));
    }

    //3.全部字段使用示例
    $response = Requests::get(
        'https://xxx.example/test.api',
        ['Content-Type: text/html;charset=utf-8'],
        ['timeout'=>10]
    );


    if(!$response->http_code){
        echo $response->error;
    }else{

        //注:以下2种效果是一样的
        echo $response;
        echo $response->content();

        //打印数组
        //注:接口必须返回 json 或 xml 格式数据
        //var_dump($response->toArray('json'));
        //var_dump($response->toArray('xml'));
    }
    
   

LICENSE

Apache-2.0

统计信息

  • 总下载量: 199
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 0
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固