-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathcurl-setopt-array.xml
150 lines (140 loc) · 3.96 KB
/
curl-setopt-array.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: fb382072791be80401170b0da410934b1659599e Maintainer: yago Status: ready -->
<!-- $Revision$ -->
<refentry xml:id="function.curl-setopt-array" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>curl_setopt_array</refname>
<refpurpose>Configura múltiples opciones para una transferencia cURL</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>curl_setopt_array</methodname>
<methodparam><type>resource</type><parameter>ch</parameter></methodparam>
<methodparam><type>array</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
Configura multiples opciones para una sesión cURL. Esta función
es muy útil para configurar gran cantidad de opciones cURL sin tener
que llamar cada vez <function>curl_setopt</function>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&curl.ch.description;
<varlistentry>
<term><parameter>opciones</parameter></term>
<listitem>
<para>
Un <type>array</type> especificando que opciones a configurar y con que valores.
Las keys deben contener constantes <function>curl_setopt</function> válidas o
sus integer equivalentes.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Devuelve &true; si todas las opciones se configuraron satisfactoriamente. Si una
opción no se pudo configurar devolverá &false; inmediatamente. Ignorando cualquier
otra opción en el array de <parameter>opciones</parameter>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>
Iniciando una nueva sesión cURL y capturando una página web
</title>
<programlisting role="php">
<![CDATA[
<?php
// Crea un nuevo recurso cURL
$ch = curl_init();
// set URL and other appropriate options
$options = array(CURLOPT_URL => 'http://www.example.com/',
CURLOPT_HEADER => false
);
curl_setopt_array($ch, $options);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
]]>
</programlisting>
</example>
</para>
<para>
Anterior a PHP 5.1.3 esta función puede ser simulada con:
</para>
<para>
<example>
<title>O nuestra implementación de <function>curl_setopt_array</function></title>
<programlisting role="php">
<![CDATA[
<?php
if (!function_exists('curl_setopt_array')) {
function curl_setopt_array(&$ch, $curl_options)
{
foreach ($curl_options as $option => $value) {
if (!curl_setopt($ch, $option, $value)) {
return false;
}
}
return true;
}
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Igual que <function>curl_setopt</function>, si se pasa un array a
<constant>CURLOPT_POST</constant> codificará los datos como
<emphasis>multipart/form-data</emphasis>, mientras que si pasa una
cadena URL-encoded codificará los datos como
<emphasis>application/x-www-form-urlencoded</emphasis>.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>curl_setopt</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->