Xcom
PHP Manual

Xcom::sendAsync

(PECL xcommerce >= 1.0.0)

Xcom::sendAsyncSend a message asynchronously

Description

public int Xcom::sendAsync ( string $topic , mixed $data [, string $json_schema [, array $http_headers ]] )

Send a message to a capability (API provider) for a topic asynchronously (using pthreads).

Liste de paramètres

If json_schema is specified, the data must be an object and is encoded as an avro-encoded message.

If json_schema is not specified, the data will be converted to a string and sent.

topic

The topic path (ie, /store/get/orders).

data

The data to be sent.

json_schema

The avro JSON schema if data is an object, if left empty there is no avro encoding.

http_headers

HTTP client headers (such as User-Agent, Accept, etc.)

Valeurs de retour

Returns 0.

Exemples

Exemple #1 Xcom::sendAsync() example (avro)

<?php
$schema 
file_get_contents('http://api.x.com/ocl/com.x.example.v1/OrderFulfillment/OrderShipped/1.2.0/');

$data = new stdClass();
$data->orderID "123495585343";

$xcom = new Xcom(XCOM_FABRIC_SANDBOX"fabric_token""capability_token");

$xcom->sendAsync("/com.x.example.v1/OrderFulfillment/OrderShipped"$data$schema);
?>

Exemple #2 Xcom::sendAsync() example (arbitrary payload)

<?php

$xcom 
= new Xcom(XCOM_FABRIC_PRODUCTION"fabric_token""capability_token");

$xcom->sendAsync("/get/profile"'request-payload');
?>

Voir aussi


Xcom
PHP Manual