?
Solved

PHP & Java

Posted on 2000-04-12
9
Medium Priority
?
820 Views
Last Modified: 2008-03-06
I have a java code which imports java.io & java.net. I am trying to post data into multiple sites using HTTPUrlConnection in java.  Can anybody possibly let me know whether i can re-write the same equivalent code in PHP.
0
Comment
Question by:balasundaram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 2

Accepted Solution

by:
maxkir earned 600 total points
ID: 2711207
The only thing you need is to write php3 script which posts the data.

The following code isn't tested. us111 always tests the code, but not me :(

Try using this class to POST data:
http://px.sklar.com/code.html?code_id=313

Use it this way:

$hp=new http_post;

// Setup data to post:
$hp->set_element(array("username" => "John Doe",
                                     "password" => "dead-ringer",
                                     "age" => "99"));
$a->set_timeout(10);

while ( ... more servers to post data ...)
{
    // $hp->set_action("http://www.somehost.org:8080/incoming.php3");
   $hp->set_action($action_from_array);
   
   // send data without showing output.
   $hp->send(false);
}
0
 

Author Comment

by:balasundaram
ID: 2711723
I have got some idea and that class will be useful. I am involved in a project using PHP. I'm new to PHP. our project is job portal. Posting  resumes to other sites. We are able to post resumes using java HTTPUrlConnection. Same I tried using the http_post

<?php
require ('http_post.php3');

$hp = new http_post;

$hp->set_element(array("function"=>"post","source"=>"cm","first_name"=>"balaji3","last_name"=>"sundaram1","city"=>"bangalore","state"=>"Other","postal_code"=>"560068","country"=>"IND","phone"=>"123123","email"=>"sbala43@usa.net","job_title"=>"s/wEng","employer"=>"ramco","function"=>"ADM","resume"=>"akjbkjdbkjbsakjdbksajdbkajsbd"));

if($hp->set_action("http://server12.careermosaic.com:8080/resumes/cgi/add-resume2.cgi"))
    echo "successfully posted";
$hp->send(false);
?>

but it is not posting the value inside set_element are html page name and value. can u tell me what is the problem. Please answer me. Anyway I will accept ur good way that u showed for me. Thank u
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2711798
This line actually posts the data :
 $hp->send(false);
 and not set_action.

Hmm, by the way - are you sure that you nees POST method and not GET ?
In case when server needs GET method stuff is more simple - you don't need http_post class et all.

  Your problem seems is, probably, that
http://server12.careermosaic.com:8080/resumes/cgi/add-resume2.cgi
  address is incorrect - it doesn't work for me in any way.


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:balasundaram
ID: 2714662
I tried with the ACTION in the posting html page of carreer. The actual action on submit  was

"http://server12.careermosaic.com/resumes/cgi/add-resume2.cgi".

I tried with this also but it is not posting. Please try with this and help me. I will be thankful for u and I almost agree your way. My mail-id is
sbala43@usa.net. Thankx
0
 

Author Comment

by:balasundaram
ID: 2714665
Adjusted points from 100 to 150
0
 

Author Comment

by:balasundaram
ID: 2714666
I tried with the ACTION in the posting html page of carreer. The actual action on submit  was

"http://server12.careermosaic.com/resumes/cgi/add-resume2.cgi".

I tried with this also but it is not posting. Please try with this and help me. I will be thankful for u and I almost agree your way. My mail-id is
sbala43@usa.net. Thankx
0
 

Author Comment

by:balasundaram
ID: 2714724
Thanks maxkir, now I tried with correct url it seems to be working. Any way I will accept your comments. If there is anyting u can help me my mail-id is sbala43@usa.net
0
 

Author Comment

by:balasundaram
ID: 2714752
Thanks Maxkir it was timely and great help from u now I got an idea how to post to other sites using PHP. Please mail me if u get any idea regarding my work. I will be thankful to u.

  sbala43@usa.net or sbala12@yahoo.com

Thanks for ur timely and friendly help.

Rgds,
balaji
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2714904
Hmm. I'd be glad to help but i have no idea what is your problem now if you've got stuff working ?
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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.
Suggested Courses

765 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