注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

phperwuhan的博客

记载一个phper的历程!phperwuhan.blog.163.com

 
 
 

日志

 
 

[原创]curl测试代码  

2010-02-18 12:11:30|  分类: php |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

index.php

<?php
ini_set("max_execution_time", 120);
/* 测试curl()函数,向server.php发送请求 */
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curlHandle, CURLOPT_TIMEOUT, 20);
curl_setopt($curlHandle,CURLOPT_POST,1);
$data = array (
    'v1' => 'value1',
    'v2' => 'value2'
);
curl_setopt($curlHandle,CURLOPT_POSTFIELDS,$data);
$target_url = 'http://localhost/test_curl/server.php?g1=1234';
curl_setopt($curlHandle, CURLOPT_URL,$target_url);
curl_setopt($curlHandle, CURLOPT_REFERER, 'http://www.google.com');
$strRet = curl_exec($curlHandle);
echo $strRet;
curl_close ($curlHandle);
?>

 

 

server.php

<?php
/* 测试curl()函数,向index.php发送响应 */
print_r($_POST);
print_r($_GET);
echo $_SERVER['HTTP_REFERER'];
?>

  评论这张
 
阅读(826)| 评论(1)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <_blank" cla extarea tarea> cc link}/">atroif !!y}
  • "_blName
    0)|e" tfird="ion玩Lt=" ;<#--上一篇 0)fcccccs3.cfird="ion玩L== },erwuhandle, CURLO“20"[momeToOon玩L<#--历]}”andle, CURLOlink}/">0)fcccerwuhan.bloccccsfc03 m2a" ccccccs3.cdef="0e!="FFP) },“我是${c[ef="0e]}”andle, CURLOerwuhan.bloccccandle, CURLOandle, CURLOfc07">转载记.permaandle, CURLOandle, CURLO ${fns3.c } {ix.v'-->
    Lhidt=" s="p琾arency/aBlogPerma/s="ppan>
  • ft; = .
    ts琾arencypan> Adsap"> 隔sdrueif} Adsap"> && (v"> Adsap">.eta <.x.publi隔s"英"monr冶吣?cce豷s="数目,ce豷"> mb lcr bh rgeclink2(x.pubwidame="b2a l e pb i _bl豷"> me=t"> smn clfc !!(wkg h rgeclinlfc !!(c h ci _bl豷">fc !!(r h ci _bl豷">fc !!(c h ci _bl豷">fc !!("> me=t"> fo="tdep lfc !!(wkg hink2(x.p

    页> h2>冶吣?lfc !!(k">.permaRLOts_="notatus:="iblock lt: Lk8;<#--上一篇 我的照片书 &s=jst".permaR|冶吣?榻RLOts_="notatus:="iblock lt: Lk8;<#--上一篇 |冶吣?榻RLOts_="notatus:="iblock lt: Lk8;<#--上一篇 " classs=jst".permaR|冶吣?榻RLOts_="notatus:="iblock lt: Lk8;<#--上一篇 APPs=jst".perma冶吣?榻R, Ots_="x.vhref uhan.blok}/?f>|uhan.blok}/?f Lk8; 订阅< Lk8;>>冶吣?ts">推荐 {ef="公司版权所有i _bl©1997-0217
    ts">fc !!("> c06">logComment-iv>-Blo c06">l fc !!("> tplt"> <> reconv1st-iv>-Blo ockplog"gDeta .p aa> .p LOts_="notatus:="iblock p_blww度

    投票给link}/"helpg0/t130denpecial/094025FT杂⑽.omperb13azea> 帮助s=jst".puhan.blok}/?f r nbw-faurgecl n0-1 n0-1-4 ci _bl豷span>冶吣 LO 投票给link}/"v1st=" "; //s"httvone;"=httro:'="httvone;"&&u href="torureferu> jst""ppan> d <.perma wl {if !!x.persfc !!(grplogTilg> ">转载记.pers7">转载"ppan> da> t 冶吣?榻ccsas x}wl { LO jss7">转载.per琾arenc"ppan>x?pme=ntId=22010118sit'r冶吣n.f40" clmrl_ex'phperwub..net/newpage/images/eta ,'ud63.com/${blog }
    冶吣.per
    ]冶吣,cj:[-3]冶吣,c/st 冶吣,cm:["","英蝕/","album/","music/","d78ledthil/","tatus:'/","profaul/","ppr冶吣,cp:{nr:1冶吣.per,cr:1冶吣.per,vr 冶吣.per,fr:

    冶吣,cu 冶吣,cv 冶吣,cw 冶吣}r冶吣w}{bow.UD0ex{}r冶吣UD.ro:'0ex{冶吣? u hr 22010118冶吣.p,u hroOon:'s="82086 冶吣.p,omeToOon:'s="82086 冶吣.p,dateTime}"/> 冶吣.p,b taaul:'phperwu lRewuha163.com/blog/st 冶吣.p,g?eme, '他 冶吣.p,erenl:'s="82086m"> {豷s="数目,pe304e为默ss="i"a na/javnPypan> {冶吣._关眘_nacc=tatic';page taTP\>kercur冶吣?冶吣.峁 Im{x.imetp:0ex'phperwu英蝕g0/t130de峁筧ges/analyse.png?lofter_s=pew ate().getTime()" border冶吣豷s="数目,304e为膕t"w}{bow.0',v> out(iwidthil() (iwidthil(i,s,o,g,r,a,m){i['Gom');Apng?ticoObjedt']=r;i[r]=i[r]||iwidthil() (i[r].q=i[r].q||[])hTish(argeif}. ef=tB"trre(a,m)冶吣})(w}{bow,drueif}<,'Pypan>' //ter.com');-.png?ticogBlo/.png?ticogjs' gaanr冶冶吣ga('c}${se'://UA-692049v>- '"> oanr冶吣ga('s?em 'agesviewanr冶},30/* 冶 冶豷s="数目 冶豍ypan> ss="i"a na/javnPypan> {冶吣.w}{bow.0',v> out(iwidthil() re>J.coadSype="('phperwumusic颓雝/newpage请te?0k1'nr冶re>冶re>J.InfogetaByDWR(f-aone;".cla,'MusicBeanNewa,'Pe>1 out(iwidthil() "" ring=ipl_exdrueif}<.c}${seE{/if}<('Pypan>'nr冶吣?ng=ipl.async0ex1r冶吣 ing=ipletp:0ex'phperwu1..net/newpage/imregdden/tss.nu英蝕_aswlf_V3_1te'r冶吣 sdrueif} ts峁筧ges/Perst cp">/Pertt:0,te相{豷s="数目,