$post = array(
'id' => 1,
'name' =>'neo',
);
//將陣列轉成字串
$post = http_build_query($post);
//初始化Curl
function sender($URL,$DATA){
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $XML);
//如果你需要回應的資料為XML,請設定 CURLOPT_RETURNTRANSFER 為true
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
//設定目的網址
$url = "目的網址";
//執行傳送並取得回應資料
$receive = sender( $url, $post);
2013年12月31日 星期二
2013年11月22日 星期五
解析轉換SOAP XML資料
XML範例:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<RestnoResponse xmlns="http://tempuri.org/">
<RestnoResult>string</RestnoResult>
</RestnoResponse>
</soap12:Body>
</soap12:Envelope>
取出string的資料(php程式碼):
$xml = "XML範例";//也可將上範例資料存成檔案,再以file_get_contents()來取出資料$soap = simplexml_load_string($xml);$response = $soap->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children()->RestnoResponse;$string = (string) $response->RestnoResult;
2013年8月27日 星期二
Synology NAS date 命令 - 昨天與前天
#昨天
需要透過時間標記來運算值 60s*60m*24h = 86400,用今天減去運算值
/bin/date -D "%s" -d $(( $(/bin/date +%s ) - 86400 )) +%Y-%m-%d
#前天
需要透過時間標記來運算值 60s*60m*24h*2d = 172800,用今天減去運算值
/bin/date -D "%s" -d $(( $(/bin/date +%s ) - 172800 )) +%Y-%m-%d
需要透過時間標記來運算值 60s*60m*24h = 86400,用今天減去運算值
/bin/date -D "%s" -d $(( $(/bin/date +%s ) - 86400 )) +%Y-%m-%d
#前天
需要透過時間標記來運算值 60s*60m*24h*2d = 172800,用今天減去運算值
/bin/date -D "%s" -d $(( $(/bin/date +%s ) - 172800 )) +%Y-%m-%d
訂閱:
文章 (Atom)