Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.45 KB | None | 0 0
  1. <?php function tradeItemIdFind($productId,$supplierGLN){
  2.     global $response;
  3.     $ch = curl_init();                                                      
  4.     curl_setopt($ch, CURLOPT_URL, "https://api.2ba.nl/1/json/TradeItem/ForProductB?productId=".$productId."&supplierglns=".$supplierGLN);
  5.     curl_setopt($ch, CURLOPT_POST, 1);
  6.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  7.     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  8.        
  9.         'Content-Type: application/json',
  10.         'Authorization: Bearer ' . $response["access_token"]
  11.     ));
  12.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13.     $server_output = curl_exec($ch);
  14.     curl_close($ch);
  15.     return $server_output;
  16. }
  17.  
  18. $server_output = tradeItemIdFind(57002171,8714252002430);
  19. ?>
  20. output:
  21.  
  22. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
  23. <HTML><HEAD><TITLE>Length Required</TITLE>
  24. <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
  25. <BODY><h2>Length Required</h2>
  26. <hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
  27. </BODY></HTML>
  28.  
  29.  
  30.  
  31.  
  32. <?php
  33. function tradeItemIdFind($productId,$supplierGLN){
  34.     global $response;
  35.     $ch = curl_init();                                                      
  36.     curl_setopt($ch, CURLOPT_URL, "https://api.2ba.nl/1/json/TradeItem/ForProductB");
  37.     curl_setopt($ch, CURLOPT_POST, 1);
  38.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  39.     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  40.        
  41.         'Content-Type: application/json',
  42.         'Authorization: Bearer ' . $response["access_token"]
  43.     ));
  44.     curl_setopt($ch, CURLOPT_POSTFIELDS,
  45.         json_encode(array(
  46.             'query' => $productId,
  47.             'suppliers' => array($supplierGLN),
  48.         )));
  49.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  50.     $server_output = curl_exec($ch);
  51.     curl_close($ch);
  52.     return $server_output;
  53. }
  54.  
  55. $server_output = tradeItemIdFind(57002171,8714252002430);
  56.  
  57. ?>
  58.  
  59.  
  60. OUTPUT:
  61.  
  62. <?xml version="1.0" encoding="utf-8"?>
  63. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  64. <html xmlns="http://www.w3.org/1999/xhtml">
  65.   <head>
  66.     <title>Service</title>
  67.     <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>
  68.   </head>
  69.   <body>
  70.     <div id="content">
  71.       <p class="heading1">Service</p>
  72.       <p>Method not allowed.</p>
  73.     </div>
  74.   </body>
  75. </html>
  76. <?php
  77. function tradeItemIdFind($productId,$supplierGLN){
  78.     global $response;
  79.     $ch = curl_init();                                                      
  80.     curl_setopt($ch, CURLOPT_URL, "https://api.2ba.nl/1/json/TradeItem/ForProductB");
  81.     curl_setopt($ch, CURLOPT_POST, 1);
  82.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  83.  
  84.     $post_data = array(
  85.         "productId" => $productId,  
  86.         "supplierglns" => $supplierGLN
  87.     );
  88.  
  89.     $post_data = json_encode($post_data);
  90.     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  91.  
  92.         'Content-Type: application/json',
  93.         'Authorization: Bearer ' . $response["access_token"],
  94.         'Content-Length: ' . strlen($post_data)
  95.     ));
  96.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  97.     $server_output = curl_exec($ch);
  98.     curl_close($ch);
  99.     return $server_output;
  100. }
  101.  
  102. $server_output = tradeItemIdFind(57002171,8714252002430);
  103. ?>
  104.  
  105.  
  106. Output: empty response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement