mariom Posted August 4, 2009 Share Posted August 4, 2009 hey guys, I've been trying to post data to a remote site from my server and capture the results. Is there someone who can help me with that? I'm sort of desperate at this point. Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/ Share on other sites More sharing options...
jonsjava Posted August 4, 2009 Share Posted August 4, 2009 can you give us a clue? We prolly could help, but we would need to know what kind of data it returns. if it's a standard website, You'll most likely need to use CuRL, if it's XML or SOAP, that's different. There are many ways to do it, but we would need more information to give a decent answer. Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890549 Share on other sites More sharing options...
micah1701 Posted August 4, 2009 Share Posted August 4, 2009 your subject line says "remote file" but your message say's "remote site" which is it? the first one is easy, the latter is a bit trickier as cross-site-scripting is difficult if you don't administer the second site. your best bet then is screen-scraping. what exactly are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890551 Share on other sites More sharing options...
Maq Posted August 4, 2009 Share Posted August 4, 2009 Is there someone who can help me with that? Yes. Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890610 Share on other sites More sharing options...
mariom Posted August 4, 2009 Author Share Posted August 4, 2009 Sorry about the delay everyone, I've been searching the internet and trying stuff . The problem is, I have to authenticate users using an authentication file from another server. I need to take their data from my page to the remote authentication page then gather the results from that page back to my page. Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890713 Share on other sites More sharing options...
WolfRage Posted August 4, 2009 Share Posted August 4, 2009 CURL is your best bet. But if you want an alternative try this: <?php $data=array('foo'=>'bar','bar'=>'baz'); $data=http_build_query($data); $context_options=array('http'=>array('method'=>'POST', 'header'=>"Content-type: application/x-www-form-urlencoded\r\n". 'Content-Length: '.strlen($data)."\r\n", 'content'=>$data)); $context=stream_context_create($context_options); $fp=file_get_contents('http://127.0.0.1/test2.php', FALSE, $context); var_dump($fp); ?> Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890723 Share on other sites More sharing options...
mariom Posted August 4, 2009 Author Share Posted August 4, 2009 Thanks for that script WolfRage, It worked on my local environment. I'm about to try calling a jsp file on another server. Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890758 Share on other sites More sharing options...
mariom Posted August 4, 2009 Author Share Posted August 4, 2009 Hey guys, I'm using the latest version of phpmailer. Is it possible to authenticate a user without sending them mail? I'm using SMTP by the way. That's the only way I could get around my woes right now. Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890777 Share on other sites More sharing options...
sawade Posted August 4, 2009 Share Posted August 4, 2009 Hey guys, I'm using the latest version of phpmailer. Is it possible to authenticate a user without sending them mail? I'm using SMTP by the way. That's the only way I could get around my woes right now. Since you state who you are sending the email to, you can define it anyway you want. Here is an example. require_once "Mail.php"; $to = "Me <me@email.com>"; $headers["From"] = "Me <me@email.com>"; $headers["Subject"] = "My Email"; $smtp["host"] = "localhost"; $smtp["port"] = "26"; $smtp["auth"] = true; $smtp["username"] = "user@email.com"; $smtp["password"] = "password"; $msg = "This is what I want to say."; // Sends the email $mail = Mail::factory('smtp', $smtp); $mail->send($to, $headers, $msg) or die('Error while processing your submission.'); Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890796 Share on other sites More sharing options...
mariom Posted August 4, 2009 Author Share Posted August 4, 2009 thanks sawade, that was cool; and worked with a little tweaking. The big challenge is now here. I now need to create email accounts. It implements a mysql database, SMTP,POSTFIX, and the frontend is squirrelmail. any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/168798-post-data-to-a-remote-file/#findComment-890895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.