Curl Post method executing more than once

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • satishdas
    New Member
    • Feb 2007
    • 2

    #1

    Curl Post method executing more than once

    Hi

    I am using the following curl code to post into a ASPX url. When I do the execute, curl is posting and getting the result more than once. I am not sure why. Can anyone help me on this.
    [php]
    <?php
    $ch = curl_init();
    $POSTFIELDS = "UserName=test& Password=testpa pi&Name=geek";

    $LOGINURL= "http://localhost/fun.aspx";

    curl_setopt($ch , CURLOPT_USERAGE NT, $useragent);
    curl_setopt($ch , CURLOPT_CONNECT TIMEOUT, 0);
    curl_setopt($ch , CURLOPT_TIMEOUT , 0);
    curl_setopt($ch ,CURLOPT_URL,$L OGINURL);
    curl_setopt($ch ,CURLOPT_POST,1 );
    curl_setopt($ch ,CURLOPT_POSTFI ELDS,$POSTFIELD S);
    curl_setopt($ch , CURLOPT_RETURNT RANSFER, 1);
    @extract($_REQU EST)
    if($result = curl_exec($ch))
    {
    echo "<pre>".$result ."</pre>";
    curl_close($ch) ;
    unset($ch);
    exit;
    }
    echo $result;
    ?>[/php]

    Please read the Posting Guidelines before you post in this forum!.
    Especially the part about enclosing code within php or code tags.

    moderator
    Last edited by ronverdonk; Feb 12 '07, 12:57 PM. Reason: enclose code in tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Are you definitely certain that you do not execute your script twice?
    Because the posted code looks fine, apart from the erroneous @extract($_REQU EST) statement and the non-initialized $useragent variable.. That must return an error to you.

    Ronald :cool:

    Comment

    • satishdas
      New Member
      • Feb 2007
      • 2

      #3
      Hi

      Yes I am sure about that. It executes again and again and returns value. I am totally confused with this. Please help

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        In that case the only way to get on with this is to see the code of the scripts involved.

        And do not forget to enclose code within php or code tags!!
        • the script that calls this script
        • the complete (error free) code of this script, because the code shown does not run without errors


        Ronald :cool:

        Comment

        • dougyitbos
          New Member
          • Mar 2007
          • 2

          #5
          I have the same problem in PHP.

          Here's the code.

          Code:
          $url="http://www.somesite.com/api/integration.asp";
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt ($ch, CURLOPT_POST, 1);
          curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
          curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
          $store = curl_exec ($ch);
          $content = curl_exec ($ch); # This returns HTML
          curl_close ($ch);
          I get a success from the page I am posting to.
          It gives me the "job ID" I was expecting... but for some reason the application I am posting to actually creates two jobs.

          :(

          Comment

          • dougyitbos
            New Member
            • Mar 2007
            • 2

            #6
            Sorry that was a debug version where I PURPOSEFULLY made multiple calls.
            I was thinking that perhaps setting the execute to a variable was causing oddness.
            The $store version isn't in the code.

            Comment

            Working...