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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.33 $ -->
<refentry xml:id="function.curl-setopt" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>curl_setopt</refname>
<refpurpose>Set an option for a cURL transfer</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>curl_setopt</methodname>
<methodparam><type>resource</type><parameter>ch</parameter></methodparam>
<methodparam><type>int</type><parameter>option</parameter></methodparam>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
Sets an option on the given cURL session handle.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&curl.ch.description;
<varlistentry>
<term><parameter>option</parameter></term>
<listitem>
<para>
The <literal>CURLOPT_XXX</literal> option to set.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be set on <parameter>option</parameter>.
</para>
<para>
<parameter>value</parameter> should be a bool for the
following values of the <parameter>option</parameter> parameter:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Option</entry>
<entry>Set <parameter>value</parameter> to</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>CURLOPT_AUTOREFERER</constant></entry>
<entry>
&true; to automatically set the <literal>Referer:</literal> field in
requests where it follows a <literal>Location:</literal> redirect.
</entry>
<entry>
Available since PHP 5.1.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_BINARYTRANSFER</constant></entry>
<entry>
&true; to return the raw output when
<constant>CURLOPT_RETURNTRANSFER</constant> is used.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_COOKIESESSION</constant></entry>
<entry>
&true; to mark this as a new cookie "session". It will force libcurl
to ignore all cookies it is about to load that are "session cookies"
from the previous session. By default, libcurl always stores and
loads all cookies, independent if they are session cookies are not.
Session cookies are cookies without expiry date and they are meant
to be alive and existing for this "session" only.
</entry>
<entry>
Available since PHP 5.1.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_CRLF</constant></entry>
<entry>
&true; to convert Unix newlines to CRLF newlines
on transfers.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_DNS_USE_GLOBAL_CACHE</constant></entry>
<entry>
&true; to use a global DNS cache. This option is
not thread-safe and is enabled by default.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FAILONERROR</constant></entry>
<entry>
&true; to fail silently if the HTTP code returned
is greater than or equal to 400. The default behavior is to return
the page normally, ignoring the code.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FILETIME</constant></entry>
<entry>
&true; to attempt to retrieve the modification
date of the remote document. This value can be retrieved using
the <parameter>CURLINFO_FILETIME</parameter> option with
<function>curl_getinfo</function>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FOLLOWLOCATION</constant></entry>
<entry>
&true; to follow any
<literal>"Location: "</literal> header that the server sends as
part of the HTTP header (note this is recursive, PHP will follow as
many <literal>"Location: "</literal> headers that it is sent,
unless <constant>CURLOPT_MAXREDIRS</constant> is set).
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FORBID_REUSE</constant></entry>
<entry>
&true; to force the connection to explicitly
close when it has finished processing, and not be pooled for reuse.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FRESH_CONNECT</constant></entry>
<entry>
&true; to force the use of a new connection
instead of a cached one.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTP_USE_EPRT</constant></entry>
<entry>
&true; to use EPRT (and LPRT) when doing active
FTP downloads. Use &false; to disable EPRT and LPRT and use PORT
only.
</entry>
<entry>
Added in PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTP_USE_EPSV</constant></entry>
<entry>
&true; to first try an EPSV command for FTP
transfers before reverting back to PASV. Set to &false;
to disable EPSV.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTPAPPEND</constant></entry>
<entry>
&true; to append to the remote file instead of
overwriting it.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTPASCII</constant></entry>
<entry>
An alias of
<constant>CURLOPT_TRANSFERTEXT</constant>. Use that instead.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTPLISTONLY</constant></entry>
<entry>
&true; to only list the names of an FTP
directory.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_HEADER</constant></entry>
<entry>
&true; to include the header in the output.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_HTTPGET</constant></entry>
<entry>
&true; to reset the HTTP request method to GET.
Since GET is the default, this is only necessary if the request
method has been changed.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_HTTPPROXYTUNNEL</constant></entry>
<entry>
&true; to tunnel through a given HTTP proxy.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_MUTE</constant></entry>
<entry>
&true; to be completely silent with regards to
the cURL functions.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_NETRC</constant></entry>
<entry>
&true; to scan the <filename>~/.netrc</filename>
file to find a username and password for the remote site that
a connection is being established with.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_NOBODY</constant></entry>
<entry>
&true; to exclude the body from the output.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_NOPROGRESS</constant></entry>
<entry><para>
&true; to disable the progress meter for cURL transfers.
<note>
<para>
PHP automatically sets this option to &true;, this should only be
changed for debugging purposes.
</para>
</note>
</para></entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_NOSIGNAL</constant></entry>
<entry>
&true; to ignore any cURL function that causes a
signal to be sent to the PHP process. This is turned on by default
in multi-threaded SAPIs so timeout options can still be used.
</entry>
<entry>
Added in cURL 7.10 and PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_POST</constant></entry>
<entry>
&true; to do a regular HTTP POST. This POST is the
normal <literal>application/x-www-form-urlencoded</literal> kind,
most commonly used by HTML forms.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_PUT</constant></entry>
<entry>
&true; to HTTP PUT a file. The file to PUT must
be set with <constant>CURLOPT_INFILE</constant> and
<constant>CURLOPT_INFILESIZE</constant>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_RETURNTRANSFER</constant></entry>
<entry>
&true; to return the transfer as a string of the
return value of <function>curl_exec</function> instead of outputting
it out directly.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSL_VERIFYPEER</constant></entry>
<entry>
&false; to stop cURL from verifying the peer's
certificate. Alternate certificates to verify against can be
specified with the <constant>CURLOPT_CAINFO</constant> option
or a certificate directory can be specified with the
<constant>CURLOPT_CAPATH</constant> option.
<constant>CURLOPT_SSL_VERIFYHOST</constant> may also need to be
&true; or &false; if
<constant>CURLOPT_SSL_VERIFYPEER</constant> is disabled (it
defaults to 2).
</entry>
<entry>
&true; by default as of cURL 7.10. Default bundle installed as of
cURL 7.10.
</entry>
</row>
<row>
<entry><constant>CURLOPT_TRANSFERTEXT</constant></entry>
<entry>
&true; to use ASCII mode for FTP transfers.
For LDAP, it retrieves data in plain text instead of HTML. On
Windows systems, it will not set <literal>STDOUT</literal> to binary
mode.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_UNRESTRICTED_AUTH</constant></entry>
<entry>
&true; to keep sending the username and password
when following locations (using
<constant>CURLOPT_FOLLOWLOCATION</constant>), even when the
hostname has changed.
</entry>
<entry>
Added in PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_UPLOAD</constant></entry>
<entry>
&true; to prepare for an upload.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_VERBOSE</constant></entry>
<entry>
&true; to output verbose information. Writes
output to <literal>STDERR</literal>, or the file specified using
<constant>CURLOPT_STDERR</constant>.
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<parameter>value</parameter> should be an integer for the
following values of the <parameter>option</parameter> parameter:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Option</entry>
<entry>Set <parameter>value</parameter> to</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>CURLOPT_BUFFERSIZE</constant></entry>
<entry>
The size of the buffer to use for each read. There is no guarantee
this request will be fulfilled, however.
</entry>
<entry>
Added in cURL 7.10 and PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_CLOSEPOLICY</constant></entry>
<entry>
Either
<parameter>CURLCLOSEPOLICY_LEAST_RECENTLY_USED</parameter> or
<parameter>CURLCLOSEPOLICY_OLDEST</parameter>.
There are three other <literal>CURLCLOSEPOLICY_</literal>
constants, but cURL does not support them yet.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_CONNECTTIMEOUT</constant></entry>
<entry>
The number of seconds to wait whilst trying to connect. Use 0 to
wait indefinitely.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_DNS_CACHE_TIMEOUT</constant></entry>
<entry>
The number of seconds to keep DNS entries in memory. This
option is set to 120 (2 minutes) by default.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTPSSLAUTH</constant></entry>
<entry>
The FTP authentication method (when is activated):
<literal>CURLFTPAUTH_SSL</literal> (try SSL first),
<literal>CURLFTPAUTH_TLS</literal> (try TLS first), or
<literal>CURLFTPAUTH_DEFAULT</literal> (let cURL decide).
</entry>
<entry>
Added in cURL 7.12.2 and PHP 5.1.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_HTTP_VERSION</constant></entry>
<entry>
<parameter>CURL_HTTP_VERSION_NONE</parameter> (default, lets CURL
decide which version to use),
<parameter>CURL_HTTP_VERSION_1_0</parameter> (forces HTTP/1.0),
or <parameter>CURL_HTTP_VERSION_1_1</parameter> (forces HTTP/1.1).
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_HTTPAUTH</constant></entry>
<entry>
<para>
The HTTP authentication method(s) to use. The options are:
<parameter>CURLAUTH_BASIC</parameter>,
<parameter>CURLAUTH_DIGEST</parameter>,
<parameter>CURLAUTH_GSSNEGOTIATE</parameter>,
<parameter>CURLAUTH_NTLM</parameter>,
<parameter>CURLAUTH_ANY</parameter>, and
<parameter>CURLAUTH_ANYSAFE</parameter>.
</para>
<para>
The bitwise <literal>|</literal> (or) operator can be used to combine
more than one method. If this is done, cURL will poll the server to see
what methods it supports and pick the best one.
</para>
<para>
<parameter>CURLAUTH_ANY</parameter> is an alias for
<literal>CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM</literal>.
</para>
<para>
<parameter>CURLAUTH_ANYSAFE</parameter> is an alias for
<literal>CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM</literal>.
</para>
</entry>
<entry>
Added in PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_INFILESIZE</constant></entry>
<entry>
The expected size, in bytes, of the file when uploading a file to a
remote site.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_LOW_SPEED_LIMIT</constant></entry>
<entry>
The transfer speed, in bytes per second, that the transfer should be
below during <constant>CURLOPT_LOW_SPEED_TIME</constant> seconds
for PHP to consider the transfer too slow and abort.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_LOW_SPEED_TIME</constant></entry>
<entry>
The number of seconds the transfer should be below
<constant>CURLOPT_LOW_SPEED_LIMIT</constant> for PHP to consider
the transfer too slow and abort.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_MAXCONNECTS</constant></entry>
<entry>
The maximum amount of persistent connections that are allowed.
When the limit is reached,
<constant>CURLOPT_CLOSEPOLICY</constant> is used to determine
which connection to close.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_MAXREDIRS</constant></entry>
<entry>
The maximum amount of HTTP redirections to follow. Use this option
alongside <constant>CURLOPT_FOLLOWLOCATION</constant>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_PORT</constant></entry>
<entry>
An alternative port number to connect to.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_PROXYAUTH</constant></entry>
<entry>
The HTTP authentication method(s) to use for the proxy connection.
Use the same bitmasks as described in
<constant>CURLOPT_HTTPAUTH</constant>. For proxy authentication,
only <parameter>CURLAUTH_BASIC</parameter> and
<parameter>CURLAUTH_NTLM</parameter> are currently supported.
</entry>
<entry>
Added in cURL 7.10.7 and PHP 5.1.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_PROXYPORT</constant></entry>
<entry>
The port number of the proxy to connect to. This port number can
also be set in <constant>CURLOPT_PROXY</constant>.
</entry>
<entry>
Added in PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_PROXYTYPE</constant></entry>
<entry>
Either <parameter>CURLPROXY_HTTP</parameter> (default) or
<parameter>CURLPROXY_SOCKS5</parameter>.
</entry>
<entry>
Added in cURL 7.10 and PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_RESUME_FROM</constant></entry>
<entry>
The offset, in bytes, to resume a transfer from.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSL_VERIFYHOST</constant></entry>
<entry>
1 to check the existence of a common name in the
SSL peer certificate. 2 to check the existence of
a common name and also verify that it matches the hostname
provided.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLVERSION</constant></entry>
<entry>
The SSL version (2 or 3) to use. By default PHP will try to determine
this itself, although in some cases this must be set manually.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_TIMECONDITION</constant></entry>
<entry>
How <constant>CURLOPT_TIMEVALUE</constant> is treated.
Use <parameter>CURL_TIMECOND_IFMODSINCE</parameter> to return the
page only if it has been modified since the time specified in
<constant>CURLOPT_TIMEVALUE</constant>. If it hasn't been modified,
a <literal>"304 Not Modified"</literal> header will be returned
assuming <constant>CURLOPT_HEADER</constant> is &true;.
Use <parameter>CURL_TIMECOND_ISUNMODSINCE</parameter> for the reverse
effect. <parameter>CURL_TIMECOND_IFMODSINCE</parameter> is the
default.
</entry>
<entry>
Added in PHP 5.1.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_TIMEOUT</constant></entry>
<entry>
The maximum number of seconds to allow cURL functions to execute.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_TIMEVALUE</constant></entry>
<entry>
The time in seconds since January 1st, 1970. The time will be used
by <constant>CURLOPT_TIMECONDITION</constant>. By default,
<parameter>CURL_TIMECOND_IFMODSINCE</parameter> is used.
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<parameter>value</parameter> should be a string for the
following values of the <parameter>option</parameter> parameter:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Option</entry>
<entry>Set <parameter>value</parameter> to</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>CURLOPT_CAINFO</constant></entry>
<entry>
The name of a file holding one or more certificates to verify the
peer with. This only makes sense when used in combination with
<constant>CURLOPT_SSL_VERIFYPEER</constant>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_CAPATH</constant></entry>
<entry>
A directory that holds multiple CA certificates. Use this option
alongside <constant>CURLOPT_SSL_VERIFYPEER</constant>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_COOKIE</constant></entry>
<entry>
The contents of the <literal>"Set-Cookie: "</literal> header to be
used in the HTTP request.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_COOKIEFILE</constant></entry>
<entry>
The name of the file containing the cookie data. The cookie file can
be in Netscape format, or just plain HTTP-style headers dumped into
a file.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_COOKIEJAR</constant></entry>
<entry>
The name of a file to save all internal cookies to when the
connection closes.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_CUSTOMREQUEST</constant></entry>
<entry><para>
A custom request method to use instead of
<literal>"GET"</literal> or <literal>"HEAD"</literal> when doing
a HTTP request. This is useful for doing
<literal>"DELETE"</literal> or other, more obscure HTTP requests.
Valid values are things like <literal>"GET"</literal>,
<literal>"POST"</literal>, <literal>"CONNECT"</literal> and so on;
i.e. Do not enter a whole HTTP request line here. For instance,
entering <literal>"GET /index.html HTTP/1.0\r\n\r\n"</literal>
would be incorrect.
<note>
<para>
Don't do this without making sure the server supports the custom
request method first.
</para>
</note>
</para></entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_EGDSOCKET</constant></entry>
<entry>
Like <constant>CURLOPT_RANDOM_FILE</constant>, except a filename
to an Entropy Gathering Daemon socket.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_ENCODING</constant></entry>
<entry>
The contents of the <literal>"Accept-Encoding: "</literal> header.
This enables decoding of the response. Supported encodings are
<literal>"identity"</literal>, <literal>"deflate"</literal>, and
<literal>"gzip"</literal>. If an empty string, <literal>""</literal>,
is set, a header containing all supported encoding types is sent.
</entry>
<entry>
Added in cURL 7.10.
</entry>
</row>
<row>
<entry><constant>CURLOPT_FTPPORT</constant></entry>
<entry>
The value which will be used to get the IP address to use
for the FTP "POST" instruction. The "POST" instruction tells
the remote server to connect to our specified IP address. The
string may be a plain IP address, a hostname, a network
interface name (under Unix), or just a plain '-' to use the
systems default IP address.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_INTERFACE</constant></entry>
<entry>
The name of the outgoing network interface to use. This can be an
interface name, an IP address or a host name.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_KRB4LEVEL</constant></entry>
<entry>
The KRB4 (Kerberos 4) security level. Any of the following values
(in order from least to most powerful) are valid:
<literal>"clear"</literal>,
<literal>"safe"</literal>,
<literal>"confidential"</literal>,
<literal>"private".</literal>.
If the string does not match one of these,
<literal>"private"</literal> is used. Setting this option to &null;
will disable KRB4 security. Currently KRB4 security only works
with FTP transactions.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_POSTFIELDS</constant></entry>
<entry>
The full data to post in a HTTP "POST" operation.
To post a file, prepend a filename with <literal>@</literal> and
use the full path. This can either be passed as a urlencoded
string like '<literal>para1=val1&para2=val2&...</literal>'
or as an array with the field name as key and field data as value.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_PROXY</constant></entry>
<entry>
The HTTP proxy to tunnel requests through.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_PROXYUSERPWD</constant></entry>
<entry>
A username and password formatted as
<literal>"[username]:[password]"</literal> to use for the
connection to the proxy.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_RANDOM_FILE</constant></entry>
<entry>
A filename to be used to seed the random number generator for SSL.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_RANGE</constant></entry>
<entry>
Range(s) of data to retrieve in the format
<literal>"X-Y"</literal> where X or Y are optional. HTTP transfers
also support several intervals, separated with commas in the format
<literal>"X-Y,N-M"</literal>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_REFERER</constant></entry>
<entry>
The contents of the <literal>"Referer: "</literal> header to be used
in a HTTP request.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSL_CIPHER_LIST</constant></entry>
<entry>
A list of ciphers to use for SSL. For example,
<literal>RC4-SHA</literal> and <literal>TLSv1</literal> are valid
cipher lists.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLCERT</constant></entry>
<entry>
The name of a file containing a PEM formatted certificate.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLCERTPASSWD</constant></entry>
<entry>
The password required to use the
<constant>CURLOPT_SSLCERT</constant> certificate.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLCERTTYPE</constant></entry>
<entry>
The format of the certificate. Supported formats are
<literal>"PEM"</literal> (default), <literal>"DER"</literal>,
and <literal>"ENG"</literal>.
</entry>
<entry>
Added in cURL 7.9.3 and PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLENGINE</constant></entry>
<entry>
The identifier for the crypto engine of the private SSL key
specified in <constant>CURLOPT_SSLKEY</constant>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLENGINE_DEFAULT</constant></entry>
<entry>
The identifier for the crypto engine used for asymmetric crypto
operations.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLKEY</constant></entry>
<entry>
The name of a file containing a private SSL key.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLKEYPASSWD</constant></entry>
<entry><para>
The secret password needed to use the private SSL key specified in
<constant>CURLOPT_SSLKEY</constant>.
<note>
<para>
Since this option contains a sensitive password, remember to keep
the PHP script it is contained within safe.
</para>
</note>
</para></entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_SSLKEYTYPE</constant></entry>
<entry>
The key type of the private SSL key specified in
<constant>CURLOPT_SSLKEY</constant>. Supported key types are
<literal>"PEM"</literal> (default), <literal>"DER"</literal>,
and <literal>"ENG"</literal>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_URL</constant></entry>
<entry>
The URL to fetch. This can also be set when initializing a
session with <function>curl_init</function>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_USERAGENT</constant></entry>
<entry>
The contents of the <literal>"User-Agent: "</literal> header to be
used in a HTTP request.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_USERPWD</constant></entry>
<entry>
A username and password formatted as
<literal>"[username]:[password]"</literal> to use for the
connection.
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<parameter>value</parameter> should be an array for the
following values of the <parameter>option</parameter> parameter:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Option</entry>
<entry>Set <parameter>value</parameter> to</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>CURLOPT_HTTP200ALIASES</constant></entry>
<entry>
An array of HTTP 200 responses that will be treated as valid
responses and not as errors.
</entry>
<entry>
Added in cURL 7.10.3 and PHP 5.0.0.
</entry>
</row>
<row>
<entry><constant>CURLOPT_HTTPHEADER</constant></entry>
<entry>
An array of HTTP header fields to set.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_POSTQUOTE</constant></entry>
<entry>
An array of FTP commands to execute on the server after the FTP
request has been performed.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_QUOTE</constant></entry>
<entry>
An array of FTP commands to execute on the server prior to the FTP
request.
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<parameter>value</parameter> should be a stream resource (using
<function>fopen</function>, for example) for the following values of the
<parameter>option</parameter> parameter:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Option</entry>
<entry>Set <parameter>value</parameter> to</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>CURLOPT_FILE</constant></entry>
<entry>
The file that the transfer should be written to. The default
is <literal>STDOUT</literal> (the browser window).
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_INFILE</constant></entry>
<entry>
The file that the transfer should be read from when uploading.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_STDERR</constant></entry>
<entry>
An alternative location to output errors to instead of
<literal>STDERR</literal>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_WRITEHEADER</constant></entry>
<entry>
The file that the header part of the transfer is written to.
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<parameter>value</parameter> should be a string that is the name of a valid
callback function for the following values of the
<parameter>option</parameter> parameter:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Option</entry>
<entry>Set <parameter>value</parameter> to</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>CURLOPT_HEADERFUNCTION</constant></entry>
<entry>
The name of a callback function where the callback function takes
two parameters. The first is the cURL resource, the second is a
string with the header data to be written. The header data must
be written when using this callback function. Return the number of
bytes written.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_PASSWDFUNCTION</constant></entry>
<entry>
The name of a callback function where the callback function takes
three parameters. The first is the cURL resource, the second is a
string containing a password prompt, and the third is the maximum
password length. Return the string containing the password.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_READFUNCTION</constant></entry>
<entry>
The name of a callback function where the callback function takes
two parameters. The first is the cURL resource, and the second is a
string with the data to be read. The data must be read by using this
callback function. Return the number of bytes read. Return 0 to signal
<literal>EOF</literal>.
</entry>
<entry>
</entry>
</row>
<row>
<entry><constant>CURLOPT_WRITEFUNCTION</constant></entry>
<entry>
The name of a callback function where the callback function takes
two parameters. The first is the cURL resource, and the second is a
string with the data to be written. The data must be written by using
this callback function. Must return the exact number of bytes written
or this will fail.
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Initializing a new cURL session and fetching a web page</title>
<programlisting role="php">
<![CDATA[
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, false);
// 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>
<example>
<title>Uploading file</title>
<programlisting role="php">
<![CDATA[
<?php
/* http://localhost/upload.php:
print_r($_POST);
print_r($_FILES);
*/
$ch = curl_init();
$data = array('name' => 'Foo', 'file' => '@/home/user/test.png');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[name] => Foo
)
Array
(
[file] => Array
(
[name] => test.png
[type] => image/png
[tmp_name] => /tmp/phpcpjNeQ
[error] => 0
[size] => 279
)
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>curl_setopt_array</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:"../../../../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
-->
|