curl模擬post進行表單提交

2021-07-31 18:06:57 字數 1028 閱讀 3871

先模擬乙個post提交

<?php

header("content-type:text/html;charset=utf-8");  

$stuid = "201301013";  

$pwd = "136";  

$uri = "www.lihe.com/lihe/b.php";//這裡換成你伺服器的位址  

// 引數陣列  

$data = array (  

'stuid' => $stuid,  

'pwd' => $pwd              

);  

$ch = curl_init ();  //初始化curl  

curl_setopt ( $ch, curlopt_url, $uri );  

curl_setopt ( $ch, curlopt_post, 1 );  //使用post請求  

curl_setopt ( $ch, curlopt_header, 0 );  

curl_setopt ( $ch, curlopt_returntransfer, 1 );  

curl_setopt ( $ch, curlopt_postfields, $data);  //提交資料  

curl_setopt ( $ch, curlopt_followlocation, true);  //重定向位址也輸出  

$return = curl_exec ( $ch ); //得到返回值  

curl_close ( $ch );  //關閉  

print_r($return);  //輸出返回值   

b.php進行資料接收

<?php  

$user = $_post['stuid'];  

$pwd = $_post['pwd'];  

print_r($user);die;

/* 這裡對得到的資料進行處理

*/  

echo "成功!";  //最後輸出結果  

?> 

CURL模擬post請求

開發專案需要用curl模擬post提交乙個多維陣列資料,請求另外乙個專案的乙個介面 傳遞的引數中,有乙個引數的值為陣列,而且很可能是乙個很大的多維陣列。但是當我使用普通的curl post 提交,會報錯誤,錯誤提示如下 php notice array to string conversion 根據...

curl模擬post登入

linux下curl很簡單了,curl d post or get url 在這裡我使用的是wirshark一款抓包分析,嘗試登入校園網 沒有驗證碼 post和get需要抓包分析 這裡也順便學習了下wirshark抓包過濾 在這裡我們可以清楚的看到校園網的帳號ddddd和密碼,密碼是加密過的但是帳號...

PHP 中的CURL 模擬表單的post提交

廢話不多說啦,直接上 data username 喬峰 skill 擒龍手 headers array curl curl init 啟動乙個curl會話 curl setopt curl,curlopt url,url 要訪問的位址 curl setopt curl,curlopt ssl ver...