473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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=testpapi&Name=geek";

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

curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch,CURLOPT_URL,$LOGINURL);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@extract($_REQUEST)
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
Feb 12 '07 #1
5 4332
ronverdonk
4,258 Expert 4TB
Are you definitely certain that you do not execute your script twice?
Because the posted code looks fine, apart from the erroneous @extract($_REQUEST) statement and the non-initialized $useragent variable.. That must return an error to you.

Ronald :cool:
Feb 12 '07 #2
Hi

Yes I am sure about that. It executes again and again and returns value. I am totally confused with this. Please help
Feb 13 '07 #3
ronverdonk
4,258 Expert 4TB
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:
Feb 13 '07 #4
I have the same problem in PHP.

Here's the code.

Expand|Select|Wrap|Line Numbers
  1. $url="http://www.somesite.com/api/integration.asp";
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_URL, $url);
  4. curl_setopt ($ch, CURLOPT_POST, 1);
  5. curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
  6. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  7. $store = curl_exec ($ch);
  8. $content = curl_exec ($ch); # This returns HTML
  9. curl_close ($ch);
  10.  
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.

:(
Mar 19 '07 #5
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.
Mar 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Conrad F | last post by:
Hi, If any Microsoft people are listening.... Are there any plans for the new web language called "Curl" to be supported in .NET (ASP.NET)? I ask as Curl represents the first step to true OO...
0
by: rgparkins | last post by:
HI I have 2 problems, 1 of which is tied to PHP and 1 loosely tied, so I'll put this out there. Got a problem that I have been working on for a while now which involves implementing the...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
0
by: deacon57 | last post by:
FYI - If you are a computer scientist (or geek), this post may be for you. I wanted to log any search keywords, etc that are used on my site. I created a simple program that logs search terms...
4
by: Terry | last post by:
I'm using curl to invoke a php script on the same site/server. It works great, but if I call it again while it's still running, nothing happens. Why? Can that be fixed? Why use curl? To make...
4
by: zorro | last post by:
Hello there, I can't figure out why is it that when i use an array for my postfields it doesn't work : this works curl_setopt($curl, CURLOPT_POSTFIELDS, "clown=bozo" ); this doesn't...
0
by: existatus | last post by:
In a form there are entries like this: <input type="text" name="first_name" size="24" /> <input type="text" name="last_name" size="24" /> <input type="hidden" name="must_have" value="12345" />...
3
by: adamalton | last post by:
Hi, I am using cURL with php to submit a form to a website and then retrieve the page that comes back. That part is easy. The problem is that the site I am posting the request to displays a...
3
by: buzz2050 | last post by:
Hi all, I am using cURL for the first time. I need to login to a site and my cURL code to do the same is as follows: //curlScript.php <?php function getContent($url, $referer,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.