fmtc/fmtc-php

此包的最新版本(1.0.0)没有提供许可证信息。

一个用于与FMTC Api接口的PHP包

1.0.0 2016-03-25 19:39 UTC

README

这是官方的php包,用于与FMTC的API接口。

功能

  • 迁移数据库模式
  • 获取FMTC的feeds(json):交易、类别、类型、商家和网络
  • 处理完整和增量feeds并存储到数据库
  • 使用易于使用的API从数据库中检索记录

安装

composer require fmtc/fmtc-php

要求

  • PHP >5.4
  • 您可能需要增加超时时间,以确保较大的API调用不会失败。
ini_set('default_socket_timeout', 6000);

初始化

$fmtc = new Fmtc\Fmtc([
	'api_key' => 'api_key',
	'database' => 'database',
	'host' => 'host',
	'username' => 'username',
	'password' => 'password'
]);

获取JSON Feeds

// Note: these methods return raw json

// Deal Feed
$fmtc->dealFeed()->fetchFull();
$fmtc->dealFeed()->fetchIncremental();

// Merchant Feed
$fmtc->merchantFeed()->fetchFull();
$fmtc->merchantFeed()->fetchIncremental();

// Category Feed
$fmtc->categoryFeed()->fetchFull();

// Type Feed
$fmtc->typeFeed()->fetchFull();

// Network Feed
$fmtc->networkFeed()->fetchFull();

迁移数据库

// migrate the database
$fmtc->database()->migrate();

// rollback the migration
$fmtc->database()->rollbackMigration();

处理Feeds

// Note: these methods pull down the JSON, parse it, normalize it, and store it in the database.

// Deal Feed
$fmtc->dealFeed()->processFull();
$fmtc->dealFeed()->processIncremental();

// Merchant Feed
$fmtc->merchantFeed()->processFull();
$fmtc->merchantFeed()->processIncremental();

// Category Feed
$fmtc->categoryFeed()->processFull();

// Type Feed
$fmtc->typeFeed()->processFull();

// Network Feed
$fmtc->networkFeed()->processFull();

检索记录 这些是用于从数据库中检索记录的方法。默认情况下,结果按评级排序。方法返回单个对象或对象数组。

// Deals
$fmtc->deals()->get($dealId);
$fmtc->deals()->all([$limit, $offset]);
$fmtc->deals()->getByCategorySlug($categorySlug, [$limit, $offset]);
$fmtc->deals()->getByTypeSlug($typeSlug, [$limit, $offset]);
$fmtc->deals()->getByMerchant($merchantId, [$limit, $offset]);
$fmtc->deals()->getByMasterMerchant($masterMerchantId, [$limit, $offset]);
$fmtc->deals()->getBySearch($searchString, [$limit, $offset]);

// Merchants
$fmtc->merchants()->get($merchantId);
$fmtc->merchants()->all();
$fmtc->merchants()->getByMasterMerchant($masterMerchantId);
$fmtc->merchants()->getBySearch($searchString);

// Categories
$fmtc->categories()->get($categorySlug);
$fmtc->categories()->all();
$fmtc->categories()->getByParent($categoryParentSlug);
$fmtc->categories()->getBySearch($searchString);

// Types
$fmtc->types()->get($typeSlug);
$fmtc->types()->all();
$fmtc->types()->getBySearch($searchString);

// Networks
$fmtc->networks()->get($networkSlug);
$fmtc->networks()->all();
$fmtc->networks()->getBySearch($searchString);

// Custom Fmtc Url
$fmtc->api()->fetchUrl($url, [$options]);