Solved

PHP & Java

Posted on 2000-04-12
9
802 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
  • 6
  • 3
9 Comments
 
LVL 2

Accepted Solution

by:
maxkir earned 150 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
Technology Partners: 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
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.

726 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