+ Reply to Thread
Results 1 to 3 of 3

Thread: PHP + cURL - Post & Cookies

  1. #1
    slinkz is offline x10Hosting Member slinkz is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    1

    Question PHP + cURL - Post & Cookies

    Hello, I need to use cURL to post some data and send cookies (in the same request).

    I have no idea how to do this so please help!

    Thanks,
    tenx23

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: PHP + cURL - Post & Cookies

    Topic 1: Posting data

    PHP Code:

    <?php

    $ch 
    curl_init("http://example.com/curl_target.php");

    curl_setopt($chCURLOPT_HEADER0);  // don't want header info
     
    curl_setopt($chCURLOPT_RETURNTRANSFER1);  //  make the result the return value of curl_exec

    curl_setopt($chCURLOPT_POST1);  //  do a POST, not a GET

    curl_setopt$ch,   CURLOPT_POSTFIELDS ,     'para1=val1&para2=val2' ); // add the POST info

    $output curl_exec($ch);      // send  it

    curl_close($ch); // clean up

    echo $output;  // show the response
    Nothing is always absolutely so.

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP + cURL - Post & Cookies

    Start with the documentation for curl_setopt, which lists the options you should set. You can use curl_setopt_array rather than curl_setopt to set multiple options simultaneously, but the documentation for the latter is what you need to read.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. News Post for Curl being closed?
    By chewett in forum Free Hosting
    Replies: 2
    Last Post: 04-26-2011, 02:08 PM
  2. Cookies
    By Steeevoe in forum Programming Help
    Replies: 2
    Last Post: 02-19-2009, 02:50 PM
  3. cURL Login And Cookies and Regex
    By Tau_Zero in forum Programming Help
    Replies: 4
    Last Post: 12-12-2007, 12:29 AM
  4. Help regarding cookies !
    By DefecTalisman in forum Free Hosting
    Replies: 5
    Last Post: 08-28-2007, 11:03 AM
  5. Cookies
    By Soulstorm in forum Free Hosting
    Replies: 8
    Last Post: 05-14-2005, 08:25 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers