承接 mahmoudz/fyber-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mahmoudz/fyber-php-sdk

Composer 安装命令:

composer require mahmoudz/fyber-php-sdk

包简介

PHP SKD for Fyber.com

README 文档

README

fyber-php-sdk is a PHP SDK for Fyber.com (the most developer friendly ad monetization platform).

fyber-php-sdk is framework agnostic PHP package that can be integrated easily with Laravel 5.

IMPORTANT: I am affiliated (never been) with Fyber or any of Fyber's professional associates. This project is purely my own work and carries no endorsements other than my own.

Installation

The recommended way to install this package is via Composer.

Via Composer

A. Run this composer command:

composer require mahmoudz/fyber-php-sdk:*

Integrations

Laravel:

The package comes bundled with a Service Provider for easier integration.

  1. Register the service provider in your config/app.php:
    'providers' => array(
        ...
		mahmoudz\fyberPhpSdk\FyberPhpSdkServiceProvider::class,
    ),

The service provider will automatically alias the mahmoudz\fyberPhpSdk\Fyber class, so you can easily use the Fyber facade anywhere in your app.

  1. Publish the configuration file:
php artisan vendor:publish --provider ='mahmoudz\fyberPhpSdk\FyberPhpSdkServiceProvider'

This will add config/fyber-sdk.php to your Config directory.

Configuration

Open config/fyber-sdk.php and customze the package

    'api_key'         => 'z6ca24652116523516f2a9e5b7e02c96',
    
    'android_app_id'  => '11233',
    'ios_app_id'      => '22344',
    'web_app_id'      => '44566',
    
    'base_url'        => 'http://api.fyber.com/feed/',
    'api_version'     => '1',
    'response_format' => 'json',
    
    'offer_callback_token' => 'a2ca24652116523516f2a9e5b7e02cc3'),

Note: It's very recommended to not add your token (any sensetive data) to the config file instead reference it to a .env variable.

Usage

Get Offers

With Laravel:

The easiest way is to use it is by the Fyber facade.

$requiredData = [
    'uid'                                   => 1,
    'locale'                                => 'en',
    'device_id'                             => '2b6f22c904d137be2e2730235f5664094b831186',
    'os_version'                            => '4.1.2',
    'timestamp'                             => 9922774499,
    'google_ad_id'                          => 'eff26c67f527e6817b36935c54f8cc5cc5cffac2',
    'google_ad_id_limited_tracking_enabled' => '38400000-8cf0-11bd-b23e-20b96e40000d',
];

$offers = Fyber::getOffers($requiredData, 'android'); // supported: ios, web and android
General usage:
// inject `mahmoudz\fyberPhpSdk\Fyber`

$offers = $fyber->getOffers($data, 'web');

Validate Offers Callback

// inject `mahmoudz\fyberPhpSdk\Fyber`

$isValid = $this->fyber->isValidOfferCallback($request['amount'], $request['uid'], $request['_trans_id_'], $request['sid']);

if(!$isValid){
    // return "HTTP/1.0 400 Bad Request: wrong SID"
}

Test

To test it from your code use the following:

// create real instance from Fyber
$fyber = new Fyber();

// create another instance of Fyber and mock it
$fyberMock = Mockery::mock(Fyber::class);

// now let the function getOffers call the getOffersMock instead
$fyberMock->shouldReceive('getOffers')->once()->andReturn($fyber->getOffersMock([], ''));

Now when your code calls $this->fyber->getOffers($data, $appType); it will return the content of fyber-php-sdk/src/offers-response.json.


Laravel friendly code sample:

// create real instance from Fyber
$fyber = App::make(Fyber::class);

// create another instance of Fyber and mock it
$fyberToMock = App::make(Fyber::class);
$fyberMock = Mockery::mock(fyberToMock);
App::instance(fyberToMock, $fyberMock);

// now let the function getOffers call the getOffersMock instead
$fyberMock->shouldReceive('getOffers')->once()->andReturn($fyber->getOffersMock([], ''));

Inject mahmoudz\fyberPhpSdk\Fyber anywhere in the app and get it automatically mocked, this will also return the content of fyber-php-sdk/src/offers-response.json.

Credits

License

The MIT License (MIT).

mahmoudz/fyber-php-sdk 适用场景与选型建议

mahmoudz/fyber-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「NextPack」 「Fyber」 「Fyber SDK」 「Fyber API」 「Fyber PHP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mahmoudz/fyber-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mahmoudz/fyber-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 mahmoudz/fyber-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-21