Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CLI CURL – > PHP CURL大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

如何翻译此curl命令以使其在 php脚本中工作? curl --request POST --data-binary '@import.xml' --header "Content-Type: application/atom+xml" --header "Content-Length: 378" "http://url.com" 这不起作用: $data = array('file'=>$fi
如何翻译此curl命令以使其在 PHP脚本中工作?
curl --request POST --data-binary '@import.xml' --header "Content-Type: application/atom+xml" --header "Content-Length: 378" "http://url.com"

这不起作用:

$data = array('file'=>$fileName);                    

    $headers = array(
        'Content-Type: application/atom+xml','Content-Length: 378'
    );

$ch = curl_init(); 
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_httpHEADER,$headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,truE);
curl_setopt($ch,CURLOPT_URL,'httpL//url.com');
curl_setopt($ch,CURLOPT_BINARYTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);  
curl_exec($ch);

解决方法@H_301_10@
尝试这个:
$ch = curl_init(); 
curl_setopt($ch,array(
        'Content-Type: application/atom+xml'
    ));
curl_setopt($ch,'http://siteurl.com');
curl_setopt($ch,file_get_contents($fileName));  
curl_exec($ch);

大佬总结

以上是大佬教程为你收集整理的CLI CURL – > PHP CURL全部内容,希望文章能够帮你解决CLI CURL – > PHP CURL所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:clicurlphp