Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php function tradeItemIdFind($productId,$supplierGLN){
- global $response;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://api.2ba.nl/1/json/TradeItem/ForProductB?productId=".$productId."&supplierglns=".$supplierGLN);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Authorization: Bearer ' . $response["access_token"]
- ));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $server_output = curl_exec($ch);
- curl_close($ch);
- return $server_output;
- }
- $server_output = tradeItemIdFind(57002171,8714252002430);
- ?>
- output:
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
- <HTML><HEAD><TITLE>Length Required</TITLE>
- <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
- <BODY><h2>Length Required</h2>
- <hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
- </BODY></HTML>
- <?php
- function tradeItemIdFind($productId,$supplierGLN){
- global $response;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://api.2ba.nl/1/json/TradeItem/ForProductB");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Authorization: Bearer ' . $response["access_token"]
- ));
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- json_encode(array(
- 'query' => $productId,
- 'suppliers' => array($supplierGLN),
- )));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $server_output = curl_exec($ch);
- curl_close($ch);
- return $server_output;
- }
- $server_output = tradeItemIdFind(57002171,8714252002430);
- ?>
- OUTPUT:
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Service</title>
- <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
- </head>
- <body>
- <div id="content">
- <p class="heading1">Service</p>
- <p>Method not allowed.</p>
- </div>
- </body>
- </html>
- <?php
- function tradeItemIdFind($productId,$supplierGLN){
- global $response;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://api.2ba.nl/1/json/TradeItem/ForProductB");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $post_data = array(
- "productId" => $productId,
- "supplierglns" => $supplierGLN
- );
- $post_data = json_encode($post_data);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Authorization: Bearer ' . $response["access_token"],
- 'Content-Length: ' . strlen($post_data)
- ));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $server_output = curl_exec($ch);
- curl_close($ch);
- return $server_output;
- }
- $server_output = tradeItemIdFind(57002171,8714252002430);
- ?>
- Output: empty response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement