Xcom
PHP Manual

Xcom::send

(PECL xcommerce >= 1.0.0)

Xcom::sendSend a message

Description

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

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

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 the HTTP response code, or FALSE on failure.

Exemples

Exemple #1 Xcom::send() 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");

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

/*
* Output:
* int(200)
*/
?>

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

<?php

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

var_dump($xcom->send("/get/profile"'request-payload'));

/*
* Output:
* int(200)
*/
?>

Voir aussi


Xcom
PHP Manual