@sanjay我会尝试给你一个当我在做Flowgear通过PHP遵循here的说明。
我不确定您是否还通过PHP或任何其他语言调用Flowgear REST API,但不管我是否认为逻辑应该保持不变。
我所做的就是将PHP CURL示例代码包装在一个类中,以便我可以重用它。以下是我为一个简单的选择查询编写的代码:
<?php
//Require the FlowgearConnect class
require_once '/path/to/flowgear_class_with_api_call.php';
try{
$workflow = new FlowgearConnect(return include 'endpoints.php');
$serial = $_POST['serial'];
$clientId = $_POST['client_id'];
//Get the results
$sql = '';
if(empty($serial)){
$conditions = sprintf(' `a`.`client_id` = %s AND `a`.`serial` > -1 ORDER BY `a`.`serial` ASC', $clientId);
}else{
$conditions = ' `a`.`serial` = ' . $serial;
}
/**
In your workflow you will most probably have a VARIABLE BAR that holds your request parameters which is what $conditions speaks to.
*/
$conditions = array('conditions' => $conditions);
$results = $workflow->getResults('orders', 'orders', $conditions);
}catch(catch any exceptions thrown by the API here){
//Log the exceptions here or do whatever
}
上面的列表应该是不言自明的。下面我将向您展示我从FlowgearConnect类中使用的功能。这不是一种标准的方式,因为您可以以不同的方式配置代码以满足您的需求。
//FlowgearConnect constructor
class FlowgearConnect
{
protetced $endpoints = [];
protected $domain = "https://your-domain.flowgear.io";
public function __construct(array $endpoints)
{
$this->endpoints = $endpoints;
}
public function getResults($model, $workflow, $options= array())
{
$endpoint = $this->getEndpoint($model, $workflow);
$results = array();
if(!empty($endpoint)){
$results = FlowgearInvoke::run($authOpts, $endpoint, $options, array('timeout' => 30));
}
return $results;
}
....
}
如前所述,enpoints.php文件仅从flowgear控制台返回配置的端点和/或worflow名称数组。下面是我的怎么看起来像一个摘录:
return array(
'orders' => array(
'shipped_orders' => '/shipped_orders',
//etc
),
'items' => array(
'your_model' => '/workflow_name_from_flowgear_console',
),
);
这仅仅是用PHP Flowgear的REST API基本的选择查询。如果幸运的话,您应该按照您为工作流程配置响应主体的方式获取记录。
下面是一个典型的工作流程测试以及您应该返回到API中的内容。
我建议您首先在流水控制台上创建您的工作流程,并确保生成所需的输出并提取您想要的部分,然后将其更改为无查询,将它们移动到您的请求的变量栏并让它们基于您期望实现的目标,在运行时注入。此解释可以替代其他操作,例如更新和/或删除。最好的事情是首先了解flowgear,并确保你可以在尝试创建一个宁静的交互式应用程序之前让所有的东西都在那里工作。
注意:我已经使用这个平台一年多了,所以您可能会发现这个错误,但我希望它会引导您为您的问题寻找解决方案。如果没有,那么也许你可以创建一个回购协议,让我检查一下,看看你如何配置一切。
感谢您的简要解释,我能够获得销售价值为5000.00及以上的图书清单。但是,如果我想在我的API调用中使用包含销售值作为参数数组('saleasValue'=> 5000.00)作为curl post字段的一部分的post方法,那么我需要在工作流中配置什么?在这一刻,如果我配置我的工作流使用POST方法,而不是我得到一个异常“服务不可用”......谢谢 – Maximum86 2014-09-25 08:50:10
@LuyandaSiko,你找到POST方法的任何解决方案?我面临同样的问题。 – tejashsoni111 2015-12-31 09:52:30
@ LuyandaSiko,你有没有发现如何使用POST方法调用flowgear工作流程的任何解决方案?请帮助我我正面临问题 – sanjay 2015-12-31 10:03:44