Solved

PHP & Java

Posted on 2000-04-12
9
777 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error message using heredoc overlaps heredoc form 12 27
PHP - AJAX and MySQL it works only if the value is a number 12 33
updating the date data 12 19
is this a cms? 8 24
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

943 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now