Solved

PHP & Java

Posted on 2000-04-12
9
785 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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.

809 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