使用PHP转义CURL @符号 [英] Escaping CURL @ symbol with PHP
问题描述
我在写一个php应用程序,通过curl数据提交注册iContact电子邮件列表。但我仍然收到无效的电子邮件地址错误。我认为这可能是由于我逃避@符号,所以它看起来像%40而不是@。另外,根据curl_setopt的PHP文档与CURLOPT_POSTFIELDS:
I'm writing a php application that submits via curl data to sign up for an iContact email list. However I keep getting an invalid email address error. I think this may be due to the fact that I'm escaping the @ symbol so it looks like %40 instead of @. Also, according to the php documentation for curl_setopt with CURLOPT_POSTFIELDS:
在HTTP
POST操作中发布的完整数据。要发布一个文件,
在@前加上一个文件名并使用
完整路径。
The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path.
有反正传递@符号作为post数据通过curl在php,而不是通过urlencode运行它?
So, is there anyway to pass the @ symbol as post data through curl in php without running it through urlencode first?
推荐答案
使用 http_build_query()
,然后将它传递给 curl_setopt()
,这将导致它发送形式为 application / x-www-form-encoded
而不是 multipart / form-data
Use http_build_query()
on your data-array first before passing it to curl_setopt()
, that will lead to it sending the form as application/x-www-form-encoded
instead of multipart/form-data
(and thus the @ is not interpreted).
另外,为什么你真的关心电子邮件地址中的@?只有@是第一个字符,而不是中间的某个位置才有意义。
Also why do you really care about the @ in an email-address? It only matters if the @ is the first character, not somewhere in the middle.
这篇关于使用PHP转义CURL @符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!