SWDesk/App
JSON 배열 전송 및 수신 : Python to PHP
bizmaker
2021. 1. 13. 22:22
<전송 블럭 : Python>
data1 = {
'RequestType': 'InsertArticles',
'KeywordID': keywordID,
'Tablename':tableName,
'CollectedArticles':json.dumps(articleList)
}
res1 = requests.post(self.ServerURL, headers=self.REQUESTHEADER, data=data1)
<수신 블럭 : PHP>
echo "Inserting articles ...<br>";
$KeywordID = $_POST['KeywordID'];
$Tablename = $_POST['Tablename'];
$Datas1 = $_POST['CollectedArticles'];
$Datas1J = json_decode($Datas1, true);
foreach($Datas1J as $data1j){
$AI1 = new cArticleInfo();
$AI1->TABLENAME = $Tablename;
$AI1->URLAddress = $data1j['address'];
$AI1->KeywordID = $KeywordID;
$rst2 = $AI1->LoadArticles($conn0);
if($rst2 != NULL) continue;
$AI2 = new cArticleInfo();
$AI2->TABLENAME = $Tablename;
$AI2->SetValuesbyJSON($data1j, $KeywordID);
$AI2->InsertArticle($conn0);
}
반응형