surender/prodege-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

surender/prodege-api

最新稳定版本:v1.0.3

Composer 安装命令:

composer require surender/prodege-api

包简介

Laravel package for Prodege MR API integration

README 文档

README

A Laravel package for seamless integration with the Prodege MR API, featuring secure request signing, time offset handling, and robust response management — all wrapped in a clean, facade-based interface.

🚀 Features

  • ✅ Signed API requests with SHA-256 HMAC
  • 🕒 Time offset handling via /lookup-request-time-offset
  • 🧱 Laravel Facade support (ProdegeApi::post(...))
  • 🧠 Smart response handling with automatic message normalization
  • 🔧 Null implementation (NullProdegeService) for local/testing environments

📦 Installation

Install via Packagist:

composer require surender/prodege-api

⚙️ Configuration

php artisan vendor:publish --tag=prodege-config

Set up your .env:

 PRODEGE_API_KEY=your_api_key
 PRODEGE_SECRET=your_secret
 PRODEGE_BASE_URL=https://api.prodegemr.com

✅ Usage

use Surender\ProdegeApi\Facades\ProdegeApi;

$response = ProdegeApi::post('project-create', [
    'project_id' => 1234001,
    'project_type_id' => 1,
    'project_name' => 'Test Project',
    'loi' => 60,
    'country_id' => 1,
    'project_url' => 'http://www.google.com/?tr_id=%transid%',
    'cpi' => 2.25,
    'mobile_optimized' => 'true',
    'sample_size' => 100,
    'expected_ir' => 90
]);

if ($response->isSuccess()) {
    return response()->json([
        'message' => $response->getMessage(),
        'response' => $response->toArray(),
    ]);
}

return response()->json([
    'message' => $response->getMessage(),
    'errors' => $response->getErrorCodes(),
    'response' => $response->toArray(),
], 422);

🧰 Utilities

Generate Signed URL

$url = ProdegeApi::generateSignedUrl('target-endpoint', ['key' => 'value']);

Generate Signed Params

$params = ProdegeApi::generateSignedParams(['key' => 'value']);

🧪 Testing in Local Environment

Prevent real API calls using the NullProdegeService:

use Surender\ProdegeApi\Contracts\ProdegeApiInterface;
use Surender\ProdegeApi\Services\NullProdegeService;

$this->app->bind(ProdegeApiInterface::class, NullProdegeService::class);

🔍 ResponseHandler Methods

Method Description

  • isSuccess() Returns true if status_id is 1
  • getMessage() Gets first message (handles string or array)
  • getMessages() Gets all messages as array
  • getErrorCodes() Returns any error codes
  • toArray() Returns the raw API response

📄 License

  • MIT License. See LICENSE file.

🙌 Contributing

  • Pull requests and issues are welcome! If you're planning a big change, open an issue first to discuss.

Let me know if you want a sample Laravel controller, targeting payload format, or if you'd like me to generate a GitHub Actions workflow for automatic testing and tag-based version release 🚀

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-10