Discord
Steam
/
Developers
/
Post with PHP ..
Login/Join
Event Log
Post with PHP to remote server?
4 replies, posted
Search
In This Thread
With PHP, I would like to post to another server and get the result back. How would I do this? I know cURL can do this, but I can't figure it out.
Here: [code] <?php class curlConnection{ public function getWebPage($webPageLocation){ $curlConnection = curl_init(); curl_setopt($curlConnection, CURLOPT_URL, $webPageLocation); curl_setopt($curlConnection, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlConnection, CURLOPT_COOKIESESSION, 1); $pageContents = curl_exec($curlConnection); curl_close($curlConnection); return $pageContents; } public function postData($webPageLocation, $formData){ $commonBrowserAgents = array( "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6", "Opera/9.20 (Windows NT 6.0; U; en)", "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100222 Ubuntu/10.04 (lucid) Firefox/3.6", "Mozilla/5.0 (Windows; U; Windows NT 6.1; lt; rv:1.9.2) Gecko/20100115 Firefox/3.6", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.2) Gecko/2008092313 Ubuntu/9.25 (jaunty) Firefox/3.8", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.9 (KHTML, like Gecko) Chrome/6.0.400.0 Safari/533.9", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.370.0 Safari/533.4", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; Zune 3.0; MS-RTC LM 8)" ); $curlConnection = curl_init(); curl_setopt($curlConnection, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curlConnection, CURLOPT_COOKIESESSION, true); curl_setopt($curlConnection, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curlConnection, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt($curlConnection, CURLOPT_COOKIEFILE, 'cookies.txt'); curl_setopt($curlConnection, CURLOPT_USERAGENT, $commonBrowserAgents[rand(0, count($commonBrowserAgents) - 1)]); curl_setopt($curlConnection, CURLOPT_URL, $webPageLocation); curl_setopt($curlConnection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlConnection, CURLOPT_POST, true); curl_setopt($curlConnection, CURLOPT_HEADER, false); curl_setopt($curlConnection, CURLOPT_POSTFIELDS, $formData); curl_exec($curlConnection); $returnPageInformation = curl_getinfo($curlConnection); curl_close($curlConnection); return $returnPageInformation; } } ?> [/code] [editline]25th October 2010[/editline] Pretty self explanatory. Or so I think.
You never ended the array
Yeah I did. );
[QUOTE=andersonmat;25647145]Yeah I did. );[/QUOTE] Oh, it seems to not show the slider bar on my iPod. Thanks.
Sorry, you need to
Log In
to post a reply to this thread.