ãã®èšäºã¯ãŸã 誰ãã®ããã®æ å ±æºã§ããããšã«æ°ä»ããŸããã
ã³ãŒããããç°¡åã«ããããã«ãªãã¡ã¯ã¿ãªã³ã°ãè¡ããŸããã éäžã§ãããã€ãã®è¿·æãªãã°ãä¿®æ£ããŸããã
æçµæŽæ°æ¥2019-11-18
ãã¹ãã¿ã¹ã¯ã®å®äºãªã©ãã»ã«ããã¬ãŒãã³ã°ã®æ¹æ³ããããŸãã ãã®å©ç¹ã¯ãã¿ã¹ã¯ã®ããªã¥ãŒã ãæéã§ãããæéãå¶éãããããšã§ãã ããã¯ãç¡éã«ãŽã ãåŒã£åŒµã£ããã建ç¯ã®åã³ã®ã²ãããã«ãŒã«ãç¡æ倢äžã§æãããšãèš±å¯ããŸããã
ãã®ãããªã¹ãã«ãã¬ãŒãã³ã°ã®çŽ æŽãããããŒãã¹ã¯ãæ°ãããã¯ãããžãŒãšããžãã¹ããã»ã¹ã«ç²Ÿéããããšã§ããããã¯ããšããããå®éã®ã¿ã¹ã¯ã§éèŠããããŸãã
ä»åã¯ãMy WarehouseãµãŒãã¹ã§é¡§å®¢æ³šæãäœæããããŒãžãäœæããå¿ èŠããããŸããã ç§ã«ãšã£ãŠã¯ããŸãã§æã«é£ãã§ãããããªãã®ã§ããWebéçºã§ã¯åå¿è ãããããå°ãªããããã³ããšã³ãã¯äŒèã ãã§ç¥ã£ãŠããŸãããããã§ã¯ããŒãžå šäœãéçºããå¿ èŠããããŸãã
ã©ããªæ¹å€ãã¢ããã€ã¹ã倧æè¿ã§ãã
ã³ã¡ã³ãã«ã¯å€ãã®å®£èªããããŸãããç§ã®æ±ºå®ã¯éåžžã«æãããããã圌ã®ããã«é©åãªãªãã¡ã¯ã¿ãªã³ã°ãè¡ããŸããã
michael_vostrikov
äœãããããšãªããç§ã¯ãã®ã¿ã¹ã¯ã®ãªãã¡ã¯ã¿ãªã³ã°ãå°ãè¡ããŸããïŒãã ããå€æŽã§ãããã®ã¯ä»ã«ããããããããŸãïŒãåŸã§æ€çŽ¢ã§ãã®èšäºãèŠã€ãã人ãã¡ã»ã©ã§ã¯ãããŸããã
ã³ããã ã ããŒã¯ã¢ãã ã ãã©ãŒã éä¿¡ ã
è¡ããïŒ
ãã¡ãããæåã®ããšã¯ã°ãŒã°ã«ã§ãã ããã¥ã¡ã³ã ããã¥ãŒããªã¢ã«ãäŸãžã®ãªã³ã¯ã®ã¿ãã°ãŒã°ã«ã§ã-ãŒãã
ããã§ãã°ãŒã°ã«ïŒãJSON APIã¯ãç¡æãé€ããã¹ãŠã®æéã§å å ¥è ãå©çšã§ããŸãããã£ãšïŒ ãã¡ããã誰ãç§ã«ææã®ãã®ããããªãã£ãããã«ããŒãŠãè²·ããªãã£ããããã圌ããç§ã«ãã®ãããªå²ãåœãŠãäžãããªããããããäœããç¡æã®ãã®ã§æ©èœããŠããŠãåãç¶ãããšæã£ãã
ãããŠãã¡ããããmoysklad-client-npm-MySkladãµãŒãã¹APIã§å¿«é©ã«äœæ¥ã§ããJavaScriptã¯ã©ã€ã¢ã³ããã¯ã°ãŒã°ã«ã§æ€çŽ¢ãããŸããããç§ã¯JSãšãããªããã ãã«å°å¿µããŠããŸãã ãã®ãããJSã§äœãã§ãããããç解ã§ããŸããã§ããã
æåã«
æåã«è¡ãããšã¯ãããã¥ã¡ã³ãã«ç²Ÿéããããšã§ãã äŒã£ãã
2ã€ç®ã¯èšç»ãç«ãŠãããšã§ãã ã³ã³ãã€ã«æžã¿ã
èšç»ãå§ãŸãã
æåã®ã¢ã¯ã·ã§ã³ã¯æ¿èªã§ãã
2çªç®ã®ã¢ã¯ã·ã§ã³ã¯ãåœåæ³ã®ãªã¹ãã衚瀺ããããšã§ãã
ã¹ããã3-ãã€ã€ãŒæ³šæãè¿œå ããŸãã
4çªç®ã®ã¢ã¯ã·ã§ã³ã¯ãè³Œå ¥è ã®æ³šæã«ã¢ã€ãã ãè¿œå ããããšã§ãã
ç®æšã¯éæãããèšç»ã¯çµäºããŸããã
ãã°ã€ã³
APIãšã®éä¿¡ã«cUrlã䜿çšãããŠããã³ãŒããèŠãŸããã cUrlãšã¯äœããAPIãšã®éä¿¡æ¹æ³ã¯ããããŸããããã³ããŒã§ããã³ãŒããããã°ããã®é©åæ§ã確èªããã®ã¯é£ãããããŸããã ç§ã¯ãããã³ããŒãã貌ãä»ãããã¡ã€ã«ã§åŠçããŸãã-å€æããŸããã
ã³ããŒãšè²Œãä»ãã«ãããã¡ã€ã«ã®åæ ã«ã€ããŠã®è©³çŽ°ã¯èª¬æããŸãããããã«äœæ¥ã³ãŒãã瀺ããŸãã
function setupCurl($apiSettings) { $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); $userName = $apiSettings[MOYSKLAD_USERNAME]; $userPassword = $apiSettings[MOYSKLAD_PASSWORD]; curl_setopt($curl, CURLOPT_USERPWD, "$userName:$userPassword"); curl_setopt($curl, CURLOPT_USERAGENT, $apiSettings[MOYSKLAD_USER_AGENT]); return $curl; }
ã«ãŒã«ãªãã·ã§ã³ïŒ
- RETURNTRANSFER-èŠæ±ãéä¿¡ããã ãã§ãªããå¿çãèšé²ããŸãã
- USERPWD-èªèšŒã®è©³çŽ°ã
ä»ã®ãªãã·ã§ã³ã¯ããªãããããå¿ èŠãªã®ãããããŸãããæããªã³ããŒïŒããŒã¹ãã
æåã®éä¿¡åŸã«ãªã»ãããããªãã£ããšããäºå®ã§ã¯ãããŸããããæ¿èªããããŒãåãªã¯ãšã¹ãã§éä¿¡ããå¿ èŠããããšããäºå®ã§ã¯ãããŸãã...
APIãµãŒããŒãšã®ã¡ãã»ãŒãžã³ã°ã®ããã®curlãªããžã§ã¯ãã®åæåã§ããã
䜿çšæ³ïŒ
function curlExec($curlObject) { $response = curl_exec($curlObject); $curlErrorNumber = curl_errno($curlObject); if ($curlErrorNumber) { throw new Exception(curl_error($curlObject)); } return $response; }
çŽç²ãªã³ããŒã¢ã³ãããŒã¹ããçç±ãèããªãã§ãã ããã
ã¢ã€ãã ã®ãªã¹ãã衚瀺
ãã€ã€ãŒã®æ³šæã«ã¯ã1ã€ã®ã¢ã€ãã ã ãã§ã¯äžååã§ããããšãå€æããŸããããµãã©ã€ã€ãŒãšãã€ã€ãŒã®ååŒçžæã®æ³äººã瀺ãå¿ èŠããããŸãã My Warehouseã¢ã«ãŠã³ãã®ææè ã¯ãè€æ°ã®æ³äººãã«ãŠã³ã¿ãŒããŒãã£ãæã€ããšãã§ããŸã-100500ã§ããããšã¯æããã§ãããç¹å®ã®è³Œå ¥è ã®æ³šæã¯ãç¹å®ã®æ³äººã«å¯Ÿããç¹å®ã®ã«ãŠã³ã¿ãŒããŒãã£ã®æ³šæã§ãã
ãããã£ãŠãåœåæ³ãåŸ ã¡ããå¥çŽãã®åœäºè ã§ããååŒãæ±ããŸãã
æ³äºº
$curl = setCurl( $curl, $apiSettings[MOYSKLAD_API_URL] . $apiSettings[MOYSKLAD_GET_JURIDICAL_PERSON], $apiSettings[MOYSKLAD_GET_JURIDICAL_PERSON_METHOD]); $persons = getJuridicalPerson($curl); function setCurl(&$curlObject, $uri, $method) { curl_setopt($curlObject, CURLOPT_URL, $uri); curl_setopt($curlObject, CURLOPT_HTTPGET, true); switch ($method) { case MOYSKLAD_METHOD_GET: break; case MOYSKLAD_METHOD_POST: curl_setopt($curlObject, CURLOPT_POST, true); break; case MOYSKLAD_METHOD_PUT: curl_setopt($curlObject, CURLOPT_PUT, true); break; } return $curlObject; } function getJuridicalPerson($curlObject) { $response = curlExec($curlObject); $data = json_decode($response, true); $result = $data['rows']; return $result; }
å®æ°ã®æãããååããaã³ããŸãããããããšæ··åããªãããã«ãç§ã¯ãããã§ãããªã©ãã¯ã¹ããŠããŸãã ã¯ããã±ãŒã¹ïŒã¹ã€ããïŒã«ã¯ããã©ã«ãã®ãã©ã³ããããããšã¯ç¥ã£ãŠããŸãããããã©ã«ãå€ãã³ãŒãã«å ·äœåããŠãã±ãŒã¹ã®äžå¹žãªéåœã«é Œããªãæ¹ãå¿«é©ã§ãã
åAPIã³ãã³ãã«ã¯ãç¬èªã®ã¢ãã¬ã¹ãšç¬èªã®ã¡ãœããsetCurlããããã¢ãã¬ã¹ãšã¡ãœãããèšå®ããŸãã
æ³äººã®ãªã¹ããååŸããã«ã¯ãé©åãªã¢ãã¬ã¹ãšã¡ãœãããèšå®ããŸãïŒã¢ãã¬ã¹ãšã¡ãœããã¯èšå®ã§èšå®ãããèšå®ã¯é¢æ°getSettingsïŒïŒ{$ apiConfig = includeïŒ 'moysklad_curl_details.php'ïŒ; return $ apiConfig;}ã«ãã£ãŠããŒããããŸãïŒã
ãã®åŸãgetJuridicalPersonã¡ãœããã§curlãå®è¡ããJSONã§å¿çãååŸããå¿çãããè¡ãé åã®ã¿ãååŸããŸãã åä¿¡ãä¿åã延æã
ã«ãŠã³ã¿ãŒããŒãã£ã§ã¯ãåãã¢ã«ãŽãªãºã ã䜿çšããŸãïŒsetCurl => getCounterpartyãåãã¢ã«ãŽãªãºã ã«ããåœåæ³ïŒsetCurl => getNomenclatureã
ä»äºã®åŸã®2æ©ã®ãã¹ãã§ã¯ãªãã倱æ¥è ã®2æ¥éã®ãã¹ãã§ããã°ããããèªååããããšã¯å¯èœã§ãããããã¯ãä»äºããã ããã®ã¹ã¿ã€ã«ã®ãã¹ãã ã£ãã®ã§ãæ°åã害ããããšã¯ãããŸããã§ããã
ç§ã«ãšã£ãŠããã¹ãã®ç®æšã¯ãJSON APIãããããå³ããããšãçŸãããåŒãåºãããšã§ãã-ç®æšã¯ãããŸããã§ããã
åãåã£ãããŒã¿-ããã¯ãŸã£ãã質åã§ã¯ãªããæããªããšã§ã-ããã¯ããªãããŒãªããžãã¹ã§ã¯ãããŸãããããŒãžã«æã£ãŠè¡ã£ãŠããããŒãžãããããæŸãã®ãããé¢çœãã£ãã®ã§ãã
ããã³ããšã³ã
ç§ã¯ãããæ£ããè¡ãæ¹æ³ãããããŸãããç§ã¯ãããããŸããïŒ
echo '<form action="#" onsubmit="return false;" id="orderForm" ><p> :<br />'; foreach ($persons as $key => $person) { $personId = $person['id']; echo '<label for="' . $personId . '">' . $person['name'] . '</label><input type="radio" data-organization-type="1" id="' . $personId . '" name="organization"><br />'; } echo ' :<br />'; foreach ($counterparty as $key => $person) { $personId = $person['id']; echo '<label for="' . $personId . '">' . $person['name'] . '</label><input type="radio" data-counterparty-type="1" id="' . $personId . '" name="counterparty"><br />'; } echo ' :<br />'; foreach ($nomenclature as $key => $position) { $positionId = $position['id']; echo '<label for="' . $positionId . '">' . $position['name'] . ', => </label><input type="text" id="' . $positionId . '" data-position-type="1"><br />'; } echo ' <input type="submit" name=" " onclick="sendOrder();"><br /></p></form>'
äžè¬çãªã¢ã«ãŽãªãºã ïŒ
- ã»ã¯ã·ã§ã³ã®ååãæžããŸã
- ããžã·ã§ã³ã®ååãæžããŠã
- å ¥åã¿ã°ãèšè¿°ããidå±æ§ã«APIããååŸããèå¥åãèšè¿°ãã
- å±æ§ãååŸããã«ã¯å€ãå²ãåœãŠãå¿ èŠãããããã察å¿ããå±æ§data-organization-type / data-counterparty-type / data-position-typeãèšè¿°ããŸã
ïŒäžè¬çã«ããã¡ãããå€ãªãã§å±æ§ã䜿çšã§ããŸããããã®æ¹æ³ã¯ããããŸããã§ããïŒã
ã顧客泚æã®äœæããã¿ã³ãã¯ãªãã¯ãããšããã©ãŒã ã¯éä¿¡ãããŸãã-ãreturn false;ãã§ãããé¢æ°ã¯ãsendOrderïŒïŒ;ããšåŒã°ããŸãã
泚æãéä¿¡
echo ' <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function sendOrder(){ var $text_field = $('#orderForm :input:text'); var position = {}; $text_field.each(function() { var this_val = $(this).val(); var may_assign = this_val>0 || this_val !=""; var is_it_position = $(this).data('position-type'); if ( may_assign && is_it_position > 0){ position[this.id] = this_val; } }); var $radio_field = $('#orderForm :input:radio:checked'); var counterparty = {}; var organization = {}; $radio_field.each(function() { var this_val = $(this).val(); var is_it_counterparty = $(this).data('counterparty-type'); var is_it_organization = $(this).data('organization-type'); var may_assign = this_val>0 || this_val !=""; if ( may_assign && is_it_counterparty > 0){ counterparty[this.id] = this_val; } if ( may_assign && is_it_organization > 0){ organization[this.id] = this_val; } });
C JSã¯ç§ã«ã¯éæ以äžã®ããã§ãã
- $ïŒ 'ïŒorderFormïŒinputïŒtext'ïŒ; -orderFormèå¥åãæã€ã¿ã°å ã®ã¿ã€ãããã¹ããæã€ãã¹ãŠã®å ¥åã¿ã°ãéžæããŸãã
- $ text_field.each-åèŠçŽ ã«å¯ŸããŠå¿åé¢æ°ãå®è¡ããŸã
- var this_val = $ïŒthisïŒ.valïŒïŒ; -ä¿åãããå€
- var may_assign = this_val> 0 || this_valïŒ= ""; -å€ã空ã§ã¯ãªãããšãèšç®
- var is_it_position = $ïŒthisïŒ.dataïŒ 'position-type'ïŒ; -data-position-typeå±æ§ãèšå®ãããŠãããšèšç®ããã
- ifïŒmay_assign && is_it_position> 0ïŒ{position [this.id] = this_val; }-å€ã空ã§ã¯ãªãããã®å ¥åãäœçœ®ã«å¯Ÿå¿ããå Žåã察å¿ããèŠçŽ ãäœçœ®ã®é åã«è¿œå ããŸããã€ã³ããã¯ã¹ãšããŠã®èå¥åã¯äžææ§ãä¿èšŒããŸãã
æ³äººãšå¯ŸæãšãŒãžã§ã³ãã§åãã¢ã¯ãããããè¡ããŸãããåæã§ã¯ããã§ãã¯æžã¿ãç¶æ ã®ãã©ãžãªãã¿ã€ãã®ãã¹ãŠã®å ¥åãéžæããç¹ãç°ãªããŸãã
$ïŒ 'ïŒorderFormïŒinputïŒradioïŒchecked'ïŒãããã«ãinputèŠçŽ ã®å€ã¯å¿ èŠãããŸãããè³Œå ¥è ãéžæãããªã¹ãå šäœãã誰ïŒ1ïŒãç¥ãå¿ èŠãããã ãã§ãã
åŠçã«éä¿¡ããããŒã¿ã®æºåãã§ããã®ã§ããªã¯ãšã¹ããäœæããå¿ èŠããããŸãã
var postData = JSON.stringify({position : position, counterparty : counterparty , organization : organization}); console.log(postData); $.ajax({ type: "POST", url: "moyskald_add_order.php", data: postData, contentType: "application/json; charset=utf-8", dataType: "text", timeout: 10000, error: function(){ alert(" "); }, success: function(data){alert(data);}, failure: function(errMsg) { alert(errMsg); } });
ãã®ã³ããŒããŒã¹ãã«è¿œå ãããã®ã¯ãããŸãããéä¿¡æ¹æ³ã¯ãPOSTããåŠçã¯ãmoyskald_add_order.phpããããŒã¿ã¯ãapplication / json;ãã®åœ¢åŒã§è¡ãããŸãã charset = utf-8 "ã圢åŒã¯-" text "ã§ãã
ããŒã¿ã¯ãŸã£ããå¿ èŠãããŸãããããã¡ãããã泚æãæ¿èªãããŸããããŸãã¯ã泚æã®è¿œå ã«å€±æããŸããããšãŠãŒã¶ãŒã«äŒããã®ãè¯ãå£èª¿ã§ãã
次ã®å°çç¹ã§ãããåŠçãã«é²ã¿ãŸãã
åŠçäž
åŠçã§äžçºãçºçããŸããã ç§ã¯Enameikã¬ãŒããŒã§ãããXAMPPïŒWin10ã®äžïŒãéçºã«äœ¿çšããŠããŸãã ãããŠããã®ãããªäœããèšå®ãããŠããŸããéåžžã®äººãšããŠPHPã¹ã¯ãªãããžã®GETãªã¯ãšã¹ããåãåããPOSTãªã¯ãšã¹ãã¯1ãæã§ããååŸã§ããŸããã
ãã ããGETã¯ãã£ãã·ã¥ãããŠããããµãŒããŒã®å¿çãååãšãŸã£ããåãã«ãªããšããäºå®ã¯ãããŸãããç¹ã«éçºäžã®å ŽåããµãŒããŒããžãã¯ã¯5åããšã«å€æŽãããŸãã
ãã®ãããfile_get_contentsïŒãphpïŒ// inputãïŒã®åœ¢åŒã§ãã©ãã¯ããžãã¯ã䜿çšããå¿ èŠããããŸãããäœãããŠããvar_exportïŒ$ POSTïŒãå®å®ããŠãarrayïŒïŒããè¿ããããã§ãã ãšããã§ãæ£ããæ¹åãžã®äžé£ã®ããã¯ã«æè¬ããŸãã
ãããŠããã¹ãŠãç°¡åã§ãïŒ
$data = json_decode($rawData, true); $rawPosition = $data['position']; $rawCounterparty = $data['counterparty']; $rawOrganization = $data['organization'];
å ¥åã解æããŸããã
æ³äººãšååŒçžæãåŒãåºãããŸããïŒ
const FIRST_INDEX = 0; $counterpartyId = $counterpartyIdCollection[FIRST_INDEX]; $organizationId = $organizationIdCollection[FIRST_INDEX];
圢æããããªã¯ãšã¹ããã£ãŒã«ãïŒ
$textAddCustomerOrder = ' { "name": "' . time() . '", "organization": { "meta": { "href": "https://online.moysklad.ru/api/remap/1.1/entity/organization/' . $organizationId . '", "type": "organization", "mediaType": "application/json" } }, "agent": { "meta": { "href": "https://online.moysklad.ru/api/remap/1.1/entity/counterparty/' . $counterpartyId . '", "type": "counterparty", "mediaType": "application/json" } } } '; $apiSettings = getSettings(); $curl = setupCurl($apiSettings); $curl = setCurl( $curl, $apiSettings[MOYSKLAD_API_URL] . $apiSettings[MOYSKLAD_ADD_CUSTOMER_ORDER], $apiSettings[MOYSKLAD_ADD_CUSTOMER_ORDER_METHOD]); curl_setopt($curl, CURLOPT_POSTFIELDS, $textAddCustomerOrder); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($textAddCustomerOrder)) );
ãããããjson_encodeãªãã§jsonãããªãŒãºããæããªããšã«æ£ããå Žæã«èå¥åã貌ãä»ããããšãããããŸããã å¿ ãPOSTFIELDS-$ textAddCustomerOrderãHTTPHEADER-'Content-LengthïŒ'ãå®è¡ããŠãã ããã strlenïŒ$ textAddCustomerOrderïŒã
APIãµãŒããŒã«åŠçã®ãªã¯ãšã¹ããéä¿¡ããŸãïŒ$ customerOrderId = setCustomerOrderïŒ$ curlïŒãã¬ã¹ãã³ã¹ã§ 'id'ãååŸããŸãã
泚æãè¿œå ãããŸããã
ãã€ã€ãŒã®æ³šæã«ã¢ã€ãã ãè¿œå ãã
ãã©ã³ã®ãã®ã¢ã€ãã ã䜿çšãããšãjson_encodeã䜿çšããŠãªã¯ãšã¹ãããã¹ããšãäœçœ®ã«ããååã®æ°éã®floatvalããã©ãŒãããããå¿ èŠãããããšä»¥å€ã«åé¡ã¯ãããŸããã floatvalã䜿çšããªãå ŽåãAPIãµãŒããŒã¯æ°éãã£ãŒã«ãïŒããã³ããããäºçŽãã£ãŒã«ãïŒã®ãã©ãŒããããšã©ãŒãçæããŸãã
$isPositionArray = is_array($rawPosition); $orderPositions= array(); if ($isPositionArray) { foreach ($rawPosition as $id => $quantity) { $positionQuantity=floatval($quantity); $orderPositions[] = [ "quantity" =>$positionQuantity, "price"=>0, "discount"=>0, "vat"=>0, "assortment" =>[ "meta"=>[ "href"=>"https://online.moysklad.ru/api/remap/1.1/entity/product/$id", "type"=>"product", "mediaType"=>"application/json" ] ], "reserve"=>$positionQuantity, ]; } }
泚ïŒforeachïŒ$ rawPosition as $ id => $ quantityïŒãäœçœ®ã®èå¥åã¯é åã®ããŒã«æžã蟌ãŸãã泚æã®æ°éã¯é åã®èŠçŽ ã®å€ã«å«ãŸããŸãã
ç§ã®é¢šæ°Žã§ã¯ãåé åãåå¥ã«äœæãããã¹ãŠã®ãåºæ¬ãé åãäžè¬çãªããŒãã«è¿œå ããå¿ èŠããããŸããã...ããã¯é床ã®çä¿¡çã ãšæãããŸãã
顧客ã®æ³šæã«äºåéãèšå®ããå¿ èŠããããã©ããã¯ããããŸããããããã¯APIã䜿çšããä»çµã¿ãããããžãã¹äžã®èŠä»¶ã§ããããã«æãããŸãã
äŸ¡æ Œãã¢ã€ãã ããªã¹ãããããã«å¿ èŠãªã¿ã¹ã¯ãç§ã«ãšã£ãŠã¯ãäŸ¡æ Œã¯å«ãŸããŠããªãã¢ã€ãã ãšå¯Ÿå¿ããTTXã®ãªã¹ãã§ãããèããŠã¿ããšãäŸ¡æ Œã¯ãã®ãããªã¢ããªã±ãŒã·ã§ã³ã®æåã®TTXã§ããã泚æãã©ãŒã ã«ã¯äŸ¡æ ŒããããŸããããããã£ãŠ-åæ ŒããŸããã
ãªã¯ãšã¹ãAPIãéä¿¡ãããšããã¹ãŠãéåžžã«æ確ã«ãªããŸããïŒ
$jsonResponse = 'empty'; $isContainPosition = count($orderPositions)>0; if($isContainPosition ){ $jsonOrderPositions= json_encode($orderPositions); $curl = setupCurl($apiSettings); $curl = setCurl( $curl, $apiSettings[MOYSKLAD_API_URL] . $apiSettings[MOYSKLAD_ADD_ORDER_POSITION_PREFIX] . $customerOrderId . $apiSettings[MOYSKLAD_ADD_ORDER_POSITION_SUFFIX], $apiSettings[MOYSKLAD_ADD_ORDER_POSITION_METHOD]); curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonOrderPositions); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($jsonOrderPositions)) ); $jsonResponse = setCustomerOrderPosition($curl); }
èŠæ±ã³ãã³ãã®ã¢ãã¬ã¹ã¯ãããå¥åŠãªæ¹æ³ã§ãèšç®ããããŸãã
$apiSettings[MOYSKLAD_API_URL] . $apiSettings[MOYSKLAD_ADD_ORDER_POSITION_PREFIX] . $customerOrderId . $apiSettings[MOYSKLAD_ADD_ORDER_POSITION_SUFFIX]
ããã¥ã¡ã³ãã«ãããšãã/ãšã³ãã£ãã£/ customerorder / {id} /ããžã·ã§ã³ãã§ãã
ãã€ãã£ãPHPæååã®ããã«ããããåãããããæ£ããèšè¿°ããŸã-{id}ã眮ãæããŸãããAPIã³ãã³ãã®èšè¿°ã«é¢ããããŒãã³ãŒããèš±å¯ããããšã¯ã§ããŸããããã¡ããããã¹ãã®èšè¿°äžã«ã³ãã³ãã¯å€æŽãããŸããããFeng Shuiã¯ãã®ãããªã°ããŒãã«ãªãã®ãå®æ°ã«åã蟌ãå¿ èŠããããŸãã¢ãŒã¡ã³ã ããããçš®é¡ã®ãªãŒãã³ãœãŒã¹ãã¬ãŒã ã¯ãŒã¯ã®ãœãŒã¹ãèŠããšãããã«ããŒãã³ãŒããéåžžã«è¿ãããšãããããŸãããããŒãã³ãŒãã¯ãããå®è¡ããå®è¡ããŸãããå®è¡ããŸããã
ãšãããŒã°
ããã ãã§ãã APIã¯ãç¡ææéã§ãæåŸã®ã¿ãŒã³ã§ãªã¯ãšã¹ããåŠçããããã10ç§ã®ã¿ã€ã ã¢ãŠãã§ã¯äžååãªå ŽåããããŸãã æ®ãã¯å®å®ããŠåäœããŸãã 確èªããŸããã
ãã¡ãããç§ãã¡ã®ç®æšã¯ããã§ã¯ãããŸããã§ãããå²ãåœãŠã®çµæãJSON Web APIãæäœããæ¹æ³ãåŠã³ããã©ãŒã ã«æ å ±ãåºåãããµãŒããŒã¹ã¯ãªããã«åŠçããããã®ãŠãŒã¶ãŒå ¥åãæž¡ãããšã§ããã³ããšã³ããããç«ãŠãæ¹æ³ãåŠã³ãŸããã
ãã£ããŒ
PostScriptum
èšäºãæžãåã«ããphp json api my warehouseããšãããããã¯ã«ã€ããŠããå°ã詳ãã調ã¹ãŠã¿ãŸããããå€ãã®å®è£ ãèŠã€ãããŸããããJSONã§ã¯ãªãXMLã§ãã çºèŠãããããŒã¹ã®ãã¡ãããã€ãã¯å®éã«æ©èœããŠããããšã«äŒŒãŠããŸããã2017幎3æ31æ¥ä»¥éãXML APIãç¡å¹ã«ãªããšè ãããŠãããããããã¯é¢ä¿ãããŸããã
ãŸãã¯ããJSON APIã¯ãç¡æãé€ããã¹ãŠã®æéã§å å ¥è ãå©çšã§ããŸãããšåãã«ãªããŸãã
建èšçãªæ¹å€ãšæé«ã®å®è·µãžã®ãªã³ã¯ããããïŒ ç§ã¯éåçãªèŸ²æ°ã§ããããšãæ¥ããŠããŸãããããããããè¯ãã®ãªããããã¯è¯ããªãã§ããããïŒ