ベースターゲット="_blank"/> <ベースターゲット="_blank">
ホームページ >バックエンド開発 >PHPチュートリアル >PHPカール
鍦?/li>
監視跨敤PHP cURL鍙相互绠€鍗曞拰Chain夋晥鍦板幓鎶撶綉椤点€备綘鶼獙偱涼綼獙偱涼綼獙偈涼綼獙偱涼涼綼偈涼綼獙偱涼涼綼卼弁绠绠绠绠と暟鎹简銆傛棤璁烘槸射犳兂浠庝粠涓€涓摼鎺ヤ笂鍙栭儴鍒嗘暟鎹紝鎴栨栨栨舵を踏み鳴らす The湰鏂囦富瑕佽杩板鏋滀娇鐢ㄨ繖涓狿HP搴撱€?/p>
鍚敤PHP 銆?/p>锕?phpphpinfo();?锕?br />
濡傛灉浣犲彲浠ュ湪缃戦>涓婄湅鍒賞笅闈㈢殑戦〃绀篜HP cURL 搴按凡琚紑鍚€?/p>
濡傛灉穿犵湅鍒扮殑璇濓紝閭d犻渶闾箞犻渶琚琚缃 HP缃 喜鐨勮缃紝鎵畏埌php_curl .dll锛屽苟鍙栨秷鍓嶉溃鐨勫垎鍙锋敞婂氨琛屼简銆傚涓嬫嬫傚涓嬫异栬緫鏃讹紝浣犻渶瑕佹墦寮€缂栬疟鍙傛暟——鍦╟onfigure锻戒护涓婂姞涓?ldquo;–with-curl”鍙傛暟銆?/p The涓狿HP cURL瀵硅薄
$curl =curl_init();// 璁ストーリー疆犻渶瑕佹姄鍙栫殑URL
curl_setopt($curl, CURLOPT_URL, 'http://co. ;
// 璁ストーリー疆ヘッダー
// 鍏抜棴URL璇锋眰
curl_close($curl); ;// 鏄storyず銮峰緱鐨勬暟鎹?br />var_dump($data);
涓婇溃鏄姄鍙栫綉椤电殑浠g爜锛屼笅闈㈠垯鏄悜鏌栫綉椤電殑浠g爜锛屼笅闈㈠垯鏄悜鏌栫綉椤电殑浠g爜锛屼笅闈㈠垯鏄悜鏌意愦兖缃鏄悜鏌意愣缃缃垯鏄悜鏌意愣兖缃垯鏄悜鏚意愣優缃缃Congju 嵠" The鐪嫔埌锛屼娇鐢–URLOPT_POST璁ストーリー疆HTTP鍗忚鐨凯OST鏂硶锛岃€屼笉鏄疓ET鏂笉硶锛抧鍚庝相互CURLOPT_POSTFIELOST鍗忚厨房疆/POSTFIELOST锶锛岃P鍏充簬浠g悊链嶅姟鍣?/p>
<ol class="dp-xml"> <li class="alt"><span><span>锕?nbsp;?php </span></span></li> <li> <span>$</span><span class="attribute">phoneNumber</span><span> = </span><span class="attribute-value">'13912345678'</span><span>; </span> </li> <li class="alt"> <span>$</span><span class="attribute">message</span><span> = </span><span class="attribute-value">'This message was generated by curl and php'</span><span>;</span> </li> <li class="alt"> <span>$</span><span class="attribute">curlPost</span><span> = </span><span class="attribute-value">'pNUMBER='</span><span> . urlencode($phoneNumber) . </span> </li> <li class="alt"> <span>'&</span><span class="attribute">MESSAGE</span><span>=</span><span class="attribute-value">' . urlencode($message) . </span> </li> <li class="alt"> <span class="attribute-value">'</span><span>&</span><span class="attribute">SUBMIT</span><span>=</span><span class="attribute-value">Send</span><span>'; </span> </li> <li> <span>$</span><span class="attribute">ch</span><span> = </span><span class="attribute-value">curl_init</span><span>(); </span> </li> <li class="alt"><span>curl_setopt($ch, CURLOPT_URL, <br>'http://www.example.com/sendSMS.php'); </span></li> <li><span>curl_setopt($ch, CURLOPT_HEADER, 1); </span></li> <li class="alt"><span>curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); </span></li> <li><span>curl_setopt($ch, CURLOPT_POST, 1); </span></li> <li class="alt"> <span>curl_setopt($ch, CURLOPT_POSTFIELDS, <br>$curlPost);$</span><span class="attribute">data</span><span> = </span><span class="attribute-value">curl_exec</span><span>(); </span> </li> <li><span>curl_close($ch); </span></li> <li class="alt"><span>?锕?nbsp;</span></li> </ol>鍏堢簬鍏獏獏瀹癸紝璇峰弬鐪嬬浉鍏崇殑PHP cURL鎵嫔唽銆?br />
そして鍦?受跨敤PHP cURL鍙相互绠€鍗曞拰链夋晥鍦板幓鎶撶綉椤点€备綘鍙鍙渶瑕佽就屼竴琛涓剼