alkhader
alkhader

Reputation: 998

Post data from ASP website to PHP website

I am developing an opt-in/opt-out API for Mobile numbers which can be placed at the top of any website, so people can subscribe to receive an SMS to their mobile numbers.

I have the below script which basically post data between my PHP websites USING Curl which is working more than fine:

<?php

$url = "http://myserverurl.com/optin.php";
$postdata['customer_id'] = "1";
$postdata['mobilenumber'] = $_POST['mobilenumber'];

$useragent= "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" ;

$ch = curl_init();
//set some cookie details up (depending on the site)
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); //set our user agent
curl_setopt($ch, CURLOPT_POST, 1); //set how many paramaters
curl_setopt($ch, CURLOPT_URL,$url); //set the url we want to use
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); //set data to post


$result= curl_exec ($ch); //execute and get the results
curl_close ($ch);
//print $result; //display the reuslt

?>

How to apply this approach if the website is in ASP.net? Is there anything similar to Curl in ASP.net?

Thanks,

Upvotes: 0

Views: 838

Answers (2)

Vyktor
Vyktor

Reputation: 20997

After few seconds of googling you'll get this result. Which shows example using System.Net.WebRequest.

And MSDN provides example how to send post data with it.

Upvotes: 1

inquam
inquam

Reputation: 12932

Take a look at WebRequest which will make most of it possible for you, but not line by line.

Also, you COULD download curl and call it from your application (really not recommended when you have the option of WebRequest though... hehe)

Upvotes: 1

Related Questions