Solved

PHP & Java

Posted on 2000-04-12
9
771 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

759 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

20 Experts available now in Live!

Get 1:1 Help Now