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
|
<HTML
><HEAD
><TITLE
>curl_setopt</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="CURL, Client URL Library Functions"
HREF="ref.curl.html"><LINK
REL="PREVIOUS"
TITLE="curl_init"
HREF="function.curl-init.html"><LINK
REL="NEXT"
TITLE="curl_exec"
HREF="function.curl-exec.html"><META
NAME="HTTP_EQUIV"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.curl-init.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.curl-exec.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.curl-setopt"
>curl_setopt</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN8460"
></A
><P
> (PHP4 >= 4.0.2)</P
>curl_setopt -- Set an option for a CURL transfer</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN8463"
></A
><H2
>Description</H2
><DIV
CLASS="funcsynopsis"
><A
NAME="AEN8465"
></A
><P
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>bool
<B
CLASS="function"
>curl_setopt</B
>
</CODE
> (int
ch, string
option, mixed
value)</CODE
></P
><P
></P
></DIV
><P
> The <B
CLASS="function"
>curl_setopt()</B
> function will set options
for a CURL session identified by the <TT
CLASS="parameter"
><I
>ch</I
></TT
>
parameter. The <TT
CLASS="parameter"
><I
>option</I
></TT
> parameter is the
option you want to set, and the <TT
CLASS="parameter"
><I
>value</I
></TT
> is
the value of the option given by the
<TT
CLASS="parameter"
><I
>option</I
></TT
>.
</P
><P
> The <TT
CLASS="parameter"
><I
>value</I
></TT
> should be a long for the
following options (specified in the <TT
CLASS="parameter"
><I
>option</I
></TT
>
parameter):
<P
></P
><UL
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_INFILESIZE</I
></TT
>: When you are
uploading a file to a remote site, this option should be used
to tell PHP what the expected size of the infile will be.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_VERBOSE</I
></TT
>: Set this option to a
non-zero value if you want CURL to report everything that is
happening.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_HEADER</I
></TT
>: Set this option to a
non-zero value if you want the header to be included in the
output.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_NOPROGRESS</I
></TT
>: Set this option to
a non-zero value if you don't want PHP to display a progress
meter for CURL transfers
<DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
PHP automatically sets this option to a non-zero parameter,
this should only be changed for debugging purposes.
</P
></BLOCKQUOTE
></DIV
>
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_NOBODY</I
></TT
>: Set this option to a
non-zero value if you don't want the body included with the
output.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_FAILONERROR</I
></TT
>: Set this option to
a non-zero value if you want PHP to fail silently if the HTTP
code returned is greater than 300. The default behaviour is
to return the page normally, ignoring the code.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_UPLOAD</I
></TT
>: Set this option to a
non-zero value if you want PHP to prepare for an upload.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_POST</I
></TT
>: Set this option to a
non-zero value if you want PHP to do a regular HTTP POST.
This POST is a normal application/x-www-from-urlencoded kind,
most commonly used by HTML forms.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_FTPLISTONLY</I
></TT
>: Set this option to
a non-zero value and PHP will just list the names of an FTP
directory.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_FTPAPPEND</I
></TT
>: Set this option to a
non-zero value and PHP will append to the remote file instead
of overwriting it.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_NETRC</I
></TT
>: Set this option to a
non-zero value and PHP will scan your ~./netrc file to find
your username and password for the remote site that you're
establishing a connection with.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_FOLLOWLOCATION</I
></TT
>: Set this option
to a non-zero value to follow any "Location: " header that the
server sends as a part of the HTTP header (note this is
recursive, PHP will follow as many "Location: " headers that
it is sent.)
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_PUT</I
></TT
>: Set this option a non-zero
value to HTTP PUT a file. The file to PUT must be set with
the CURLOPT_INFILE and CURLOPT_INFILESIZE.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_MUTE</I
></TT
>: Set this option to a
non-zero value and PHP will be completely silent with regards
to the CURL functions.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_TIMEOUT</I
></TT
>: Pass a long as a
parameter that contains the maximum time, in seconds, that
you'll allow the curl functions to take.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_LOW_SPEED_LIMIT</I
></TT
>: Pass a long as
a parameter that contains the transfer speed in bytes per
second that the transfer should be below during
CURLOPT_LOW_SPEED_TIME seconds for PHP to consider it too slow
and abort.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_LOW_SPEED_TIME</I
></TT
>: Pass a long as
a parameter that contains the time in seconds that the
transfer should be below the CURLOPT_LOW_SPEED_LIMIT for PHP
to consider it too slow and abort.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_RESUME_FROM</I
></TT
>: Pass a long as a
parameter that contains the offset, in bytes, that you want
the transfer to start from.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_SSLVERSION</I
></TT
>: Pass a long as a
parameter that contains the SSL version (2 or 3) to use. By
default PHP will try and determine this by itself, although,
in some cases you must set this manually.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_TIMECONDITION</I
></TT
>: Pass a long as a
parameter that defines how the CURLOPT_TIMEVALUE is treated.
You can set this parameter to TIMECOND_IFMODSINCE or
TIMECOND_ISUNMODSINCE. This is a HTTP-only feature.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_TIMEVALUE</I
></TT
>: Pass a long as a
parameter that is the time in seconds since January 1st, 1970.
The time will be used as specified by the CURLOPT_TIMEVALUE
option, or by default the TIMECOND_IFMODSINCE will be used.
</P
></LI
></UL
>
</P
><P
> The <TT
CLASS="parameter"
><I
>value</I
></TT
> parameter should be a string for
the following values of the <TT
CLASS="parameter"
><I
>option</I
></TT
>
parameter:
<P
></P
><UL
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_URL</I
></TT
>: This is the URL that you
want PHP to fetch. You can also set this option when
initializing a session with the <A
HREF="function.curl-init.html"
><B
CLASS="function"
>curl_init()</B
></A
>
function.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_USERPWD</I
></TT
>: Pass a string
formatted in the [username]:[password] manner, for PHP to use
for the connection. connection.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_PROXYUSERPWD</I
></TT
>: Pass a string
formatted in the [username]:[password] format for connection
to the HTTP proxy.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_RANGE</I
></TT
>: Pass the specified range
you want. It should be in the "X-Y" format, where X or Y may
be left out. The HTTP transfers also support several
intervals, seperated with commas as in X-Y,N-M.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_POSTFIELDS</I
></TT
>: Pass a string
containing the full data to post in an HTTP "POST" operation.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_REFERER</I
></TT
>: Pass a string
containing the "referer" header to be used in an HTTP request.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_USERAGENT</I
></TT
>: Pass a string
containing the "user-agent" header to be used in an HTTP
request.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_FTPPORT</I
></TT
>: Pass a string
containing the which will be used to get the IP address to use
for the ftp "PORT" 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.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_COOKIE</I
></TT
>: Pass a string
containing the content of the cookie to be set in the HTTP
header.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_SSLCERT</I
></TT
>: Pass a string
containing the filename of PEM formatted certificate.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_SSLCERTPASSWD</I
></TT
>: Pass a string
containing the password required to use the CURLOPT_SSLCERT
certificate.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_COOKIEFILE</I
></TT
>: Pass a string
containing the name of the file containing the cookiee data.
The cookie file can be in Netscape format, or just plain
HTTP-style headers dumped into a file.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_CUSTOMREQUEST</I
></TT
>: Pass a string to
be used instead of GET or HEAD when doing an HTTP request.
This is useful for doing DELETE or another, more obscure, HTTP
request.
<DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
Don't do this without making sure your server supports the
command first.
</P
></BLOCKQUOTE
></DIV
>
</P
></LI
></UL
>
</P
><P
> The following options expect a file descriptor that is obtained
by using the <A
HREF="function.fopen.html"
><B
CLASS="function"
>fopen()</B
></A
> function:
<P
></P
><UL
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_FILE</I
></TT
>: The file where the output
of your transfer should be placed, the default is STDOUT.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_INFILE</I
></TT
>: The file where the
input of your transfer comes from.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_WRITEHEADER</I
></TT
>: The file to write
the header part of the output into.
</P
></LI
><LI
><P
> <TT
CLASS="parameter"
><I
>CURLOPT_STDERR</I
></TT
>: The file to write
errors to instead of stderr.
</P
></LI
></UL
>
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.curl-init.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.curl-exec.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>curl_init</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.curl.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>curl_exec</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|