Solved

Posting a values to a website

Posted on 2009-07-02
11
291 Views
Last Modified: 2013-12-13
hi all
 im trying to post a value to a webpage hosted by someone. My problem is the receipint website is not getting my post, im doing it like the code below.
Does anyone see what im doing wrong

                                   
$post_to_url = 'http://webadd.gsm.co.za/XML/Send'; 	

		echo $Response;

		$req = 'number=27795686787&message=testing';

                                          $Message = $_REQUEST['mesg'];

		$MobileNumber = $_REQUEST['num'];		

		//$result = mysql_query($query) or die("Couldn't select infor!55");	

		$ch = curl_init();

		echo $post_to_url;			

		curl_setopt($ch, CURLOPT_URL,$post_to_url);

		curl_setopt($ch, CURLOPT_POST, 1);

		curl_setopt($ch, CURLOPT_POSTFIELDS, $req);

		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		$buffer = curl_exec($ch);

		curl_close($ch);

		echo "Result=".$buffer;

Open in new window

0
Comment
Question by:dawie
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 5

Expert Comment

by:mallcore
ID: 24761420
Whats the $Response variable?
And are you getting that $_REQUEST from a form?
0
 

Author Comment

by:dawie
ID: 24761437
this variable $_REQUEST  is fine
my problem is when i post to the other page(its not ours/ on a different website), they dont get my post
0
 
LVL 7

Accepted Solution

by:
szewkam earned 100 total points
ID: 24761556
well on the first sight you have error in initializing connection with curl. Line 7 from you snippet should look like this:
 $ch = curl_init($post_to_url);
0
 
LVL 7

Expert Comment

by:szewkam
ID: 24761580
my mistake... i didn't notice the URL option...
0
 

Author Comment

by:dawie
ID: 24761797
thnaks i will test that
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Assisted Solution

by:mallcore
mallcore earned 100 total points
ID: 24761806
Well if I understood right, you are trying to echo a closed curl session. Once you use
curl_close($ch), it frees all system resources and $ch is also deleted.
0
 

Author Comment

by:dawie
ID: 24761848
140770FC:SSL routines:func(119):reason(252)
im getting this error message if i put an  error handler like this
curl_error($ch)
0
 
LVL 11

Assisted Solution

by:BrianMM
BrianMM earned 100 total points
ID: 24761875
From what i can hazily remember acout curl  - not touched it for ages... this error if i recall means it's not getting to the url...

so check it resolves, also they could be blocking traffic.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 24767816
The URL http://webadd.gsm.co.za/XML/Send is 404.  Let's get past that first.  Then, if the web service at http://webadd.gsm.co.za/XML/Send is expecting a POST method call, you might consider using fsockopen().  Is there any chance they are expecting a GET method call?
0
 

Author Comment

by:dawie
ID: 24847549
thnaks guys the problem was my parameter list isnt working fine, so i added everything in the webadd
i wanted to specify the params on thier own.
Thanks guys
echo "mycellnumber=".$value;

					echo "<br>"."Message=".$SendSMG;

					$SendSMG = urlencode($SendSMG);

					$username = 'test';

					$password = 'test';

					//$number = '27795686787';

					$number = $value;

					$message = 'Testing%20fromweb';

					//$url = "https://www.myadd/XML/send/?username=test&password=test&number=27733218190&message=Testing%20fromweb"; 					$url = "https://www.xml2sms.gsm.co.za/send/?username=test&password=test&number=$value&message=$SendSMG"; 		

					$ch = curl_init();

					curl_setopt($ch, CURLOPT_URL, $url);

					//curl_setopt ($ch, CURLOPT_PORT, $port);

					curl_setopt ($ch, CURLOPT_POST, 1);

					curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

					$post_body = '';

					$post_fields = array(

						username => $username,

						password => $password,

						message => $message,

						msisdn => $number

					);					

					foreach($post_fields as $key=>$value) 

					{

						$post_body .= urlencode($key).'='.urlencode($value).'&';

					}

					$post_body = rtrim($post_body,'&');
 

					curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_body);

					$response_string = curl_exec($ch);

Open in new window

0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 24849618
Let me ask this question again: Is there any chance they are expecting a GET method call?  I am asking because you have a URL in the comment on line 9 that looks like a RESTful interface call, made using the GET method.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now