API打印机点

时间:2019-03-11 10:03:48

标签: php api

我想在我的应用程序中引入api打印机点以能够使用远程打印机,但我找到了该API的库,但我不知道如何使用它: 这是图书馆

    <?php function Print_point($imprimante,$message) {
// id customer Printer Point
$sid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$data = array('sid' => $sid,'token' => $token,'params'  => array('printer_uid' => $imprimante,'printer_msg' => $message));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.expedy.fr/api/print");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec ($ch);
curl_close ($ch);

return $result;
}
?>

这是一个使用示例

 <?php

// Preparation
include "printer_point_lib.php";

$imprimante = "XXXXXXXXX";

// Your message
$msg = "Hello World !";

// To Print
Print_point($imprimante,$msg);

?>

我想知道: 我要放入$ sid,$令牌,CURLOPT_URL和$ imprimante的内容 谢谢!

1 个答案:

答案 0 :(得分:1)

您最好阅读library documentation。据我所知,您所要做的就是为它提供打印机ID $imprimante和要打印的消息$msg,仅此而已。我认为API不需要您查看类和方法。这是文档中列出的示例:

include "printer_point_lib.php";

// Your printer unique id
$imprimante = "123456789";

// Your message
$msg = "Hello World !";

Print_point($imprimante,$msg);