I'm using the limelight content API to retrieve all of my videos.
I used their examples and it is returning all media.
Here is the code:
$request = "http://api.video.limelight.com/rest/organizations/$org_id/media/search";
$signed_request = LvpAuthUtil::authenticate_request("GET", $request, $access_key, $secret, $params);
Now I want to tell it which field to sort the results by. The documentation says that there are paging parameters available, but I can't seem to get them to work.
I tried adding $params = array("and" => "sort_by:title");
and $params = array("sort_by" => "title"); but neither worked.
I also tried adding it to the url but it didn't work. http://api.video.limelight.com/rest/organizations/$org_id/media/search?sort_by=title
Can someone tell me how to pass the paging parameters correctly?
Thank You
Try this:
http://api.video.limelight.com/rest/organizations/6d4242bd0cf94083a0195bfc2083e46e/media.xml?page_id=0&page_size=50&sort_by=publish_date&sort_order=desc
Check optional parameter in List all channels that contain a specific media
Optional Parameters
page_id = <The zero-based identifier of the page to return>
page_size = <The number of results to return per page> (default/max: 500)
sort_by = <The field by which the results should be sorted> {publish_date, create_date, update_date} (default: update_date)
sort_order = <The order in which the results should display> {asc, desc} (default: asc)
Related
I need a list of index names from Elasticsearch that match a certain pattern. Using Kibana I've no problem doing this, but I simply can't figure out how to do the same with the Elasticsearch-PHP client.
Example:
Trying to get indices matching the name pattern "*.foo.bar"
With Kibana: GET /_cat/indices/*.foo.bar
Does anyone know? I've found nothing on this in the Elasticsearch-PHP docs.
I figured it out through trial and error.
The way to get a list of indices matching a pattern is:
$client = ClientBuilder::create()->build();
$indices = $client->cat()->indices(array('index' => '*.foo.bar'));
In the current docs at the time of this response (7.2), you can find the documentation for the endpoint GET /_cat/indices/ that you're looking for.
So you can get the indices with this code:
$params = [
// Example of another param
'v' => true,
// ...
'index' => '*.foo.bar'
];
$indices = $client->cat()->indices($params);
The documentation doesn't explicitly states about the index param, but you can see how the index is set inside the CatNamespace::indices() method definition.
public function indices(array $params = [])
{
$index = $this->extractArgument($params, 'index');
...
$endpoint->setIndex($index);
...
}
I need to create line chart for my twitter followers . I have used following code to list the followers details.
$parameters = array('include_user_entities' => true);
$response = $this->api->get('followers/list.json', $parameters);
Its working fine .But its doesn't probvide following date details. How can I get following date details using twitter api
If you write:
$parameters = array('include_user_entities' => true);
$parameters = array();
The second command overwrite the first. Thus $parameters contains an empty array. Try with this:
$parameters = array('include_user_entities' => true);
$response = $this->api->get('followers/list.json', $parameters);
There is no way in the API to tell when someone followed you.
Take a look at the API reference - https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list
The only date in the returned object is created_at - that refers to when the account was created, not when it followed you.
How can I set order notes in plenty market rest api ?
function setOrderNotes($orderId, $orderNote) {
// set parameter array
$params = array('referenceType'=>'order','referenceValue'=>$orderId,'text'=>$orderNote,'isVisibleForContact'=>true);
// make curl request to get order by id
$result = $this->_makeRequest('/rest/comments','POST', $params);
// return order array by order id
return $result;
}
The above code returns error instead of creating the comment (notes) for order id. Please help me on this problem ?
I have a datase table with a list of books. Below is my sql statement:
SELECT `Book`.`id` , `Book`.`name` , `Book`.`isbn` , `Book`.`quantity_in_stock` , `Book`.`price` , (`Book`.`quantity_in_stock` * `Book`.`price`) AS `sales`, concat(`Author`.`name`, ' ', `Author`.`surname`) AS `author`
FROM `books` AS `Book`
LEFT JOIN authors AS `Author`
ON ( `Book`.`author_id` = `Author`.`id` )
WHERE (`Book`.`quantity_in_stock` * `Book`.`price`) > 5000.00
The query works fine and the workflow works fine too. However, I am wanting to access this through an API and make the 5000.00 value configurable through a variable bar.
Question is how do I make this possible such that when I call my API with my endpoint below it works?
https://domain.flowgear.io/5000booklist/{sales_value}
What I want is to be able to re-use my workflow via an API and just pass a sales value I want to query the table against. Sales value can be 2000 or 5000 depending on what I want to achieve.
Add a variable bar and add a property to it called "salesValue"
In the workflow detail pane, provide this url: "/booklist/{salesValue}" - the value in braces must match the name of the property in the variable bar
Add a Formatter, put your SQL template including "WHERE (Book.quantity_in_stock * Book.price) > {salesValue}" in the Expression property then add a custom field called salesValue and pin that from the variable bar salesValue property. Set Escaping to SQL.
Take the output of the Formatter and plug that into the SQL Query property of a SQL Query Connector.
Add another variable bar, and add the special properties FgResponseBody and FgResponseContentType
Pin the SQL result to FgResponseBody and set FgResponseContentType to 'text/xml'
If you want to return JSON, convert the result from the SQL Query to JSON using JSON Convert and then pin that to FgResponseBody and set FgResponseContentType to 'application/json'
#sanjay I will try to give you an overview of what I did back then when I was experimenting with Flowgear through PHP following instructions from here.
I am not sure if you are also invoking the Flowgear REST API through PHP or any other language but regardless I presume logic should remain the same.
What I did was to wrap the PHP CURL sample code in a class so that I can be able to reuse it. Below is a code I wrote for a simple select query:
<?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
}
The listing above should be self explanatory. Below I will show you the functions I have made use of from my FlowgearConnect class. This is not a standard way as you may configure your code differently to suite your needs.
//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;
}
....
}
The enpoints.php file, as mentioned before, just returns an array of configured endpoints and/or worflow names from within flowgear console. Below is a excerpt of how mine looked like:
return array(
'orders' => array(
'shipped_orders' => '/shipped_orders',
//etc
),
'items' => array(
'your_model' => '/workflow_name_from_flowgear_console',
),
);
This is just a basic select query with Flowgear's REST API using PHP. If you are lucky you should get your records the way you have configured your response body for your workflow.
Below is a typical testing of a workflow and what you should get back in your API.
I advice you to first create your workflows on your flowgear console and make sure that the produce the desired output and the extract the parts that you want changed no your query, move them to a variable bar for your request and have them injected at run-time based on what you looking to achieve. This explanation can be substituted for other operations such as update and/or delete. Best thing is to understand flowgear first and make sure that you can have everything working there before attempting to create a restful interactive application.
Caution: It's over a year that I have since worked with this platform so you might find errors in this but I am hoping that it will lead you to finding a solution for your problem. If not then perhaps you can create a repo and have me check it out to see how you are configuring everything.
I'm trying to get products from Magento API with catalogProductList (soap v2) here is my function.
public function get_products() {
$products = array();
$login = $this->login_info();
$proxy = new SoapClient($login['url']);
$sessionId = $proxy->login($login['user'], $login['pass']);
$result = $proxy->catalogProductList($sessionId);
foreach($result as $value) {
$products[] = $proxy->catalogProductInfo($sessionId, $value->product_id);
}
echo "<pre>";
var_dump($products);
echo "</pre>";
}
However because the request it's in a loop it will make for each product a request to Magento API.
I'm wondering if there is a solution to get multiple products info (based on provided product_id) in the same request. Maybe 50 or 100 products info for each request I think will reduce a lot the time of getting all the products.
I have found on http://www.magentocommerce.com/api/soap/introduction.html
$params = array('filter' => array(
array('key' => 'status', 'value' => 'pending'),
array('key' => 'customer_is_guest', 'value' => '1')
));
$result = $client->salesOrderList($sessionId, $params);
but from my understanding it's more about filtering the products so I don't know if it helps too much.
Looks like you're calling the catalogProductList twice, first time outside the loop and the second time inside the loop passing invalid arguments, the doc here is showing that you only need to use the method once passing the session id plus you are able to pass two extra optional arguments (array of filters and the store view id or code) additionally if the returned result catalogProductEntity is not enough you can override that part of the API adding extra product information for example the media images.