sub post_to_hsuforum{ my ( $self, $user_id, $course_id, $forum_id, $post_subject, $post_message ) = @_; my $hsu_forums_post_path="/mod/hsuforum/post.php"; my $post_url="https://$self->{'fqdn'}$hsu_forums_post_path"; my $max_file_size="10485760"; my $timestart="0"; my $timeend="0"; my $reveal="0"; my $show_anony="0"; my $course="$course_id"; my $hsuforum="$forum_id"; my $discussion="0"; my $parent="0"; my $userid="$user_id"; my $edit="0"; my $reply="0"; my $sesskey="$self->{sesskey}"; my $_qf__mod_hsuforum_post_form="1"; my $subject="$post_subject"; my $message="$post_message"; my $format="1"; my $subscribe="0"; my $attachment="@/home/jchase/test.txt"; my $submitbutton="Post to forum"; my $post_field="MAX_FILE_SIZE=$max_file_size×tart=$timestart&timeend=$timeend&reveal=$reveal&show_anony=$show_anony" ."&course=$course&hsuforum=$hsuforum&discussion=$discussion&parent=$parent&userid=$userid&groupid=&edit=$edit" ."&reply=$reply&privatereply=&sesskey=$sesskey&_qf__mod_hsuforum_post_form=$_qf__mod_hsuforum_post_form&subject=$subject" ."&message=$message&format=$format&subscribe=$subscribe&attachment=$attachment&submitbutton=$submitbutton"; curl_functions::post_submit( $self->{'connection_handle'}, $post_url, $post_field ); } #### sub post_submit{ my $ch=shift; # Curl handle my $url=shift; # Url to submit form my $postfield=shift; # POST variables to submit #SET URL FOR THE POST FORM LOGIN $ch->setopt(CURLOPT_URL, "$url"); #ENABLE HTTP POST $ch->setopt(CURLOPT_POST, 1); #SET POST PARAMETERS : FORM VALUES FOR EACH FIELD $ch->setopt(CURLOPT_POSTFIELDS, "$postfield"); my $tmp_file='/tmp/post_response.txt'; open(my $write_responsefile,'>',"$tmp_file") or die "Could not open $tmp_file for write"; $ch->setopt(CURLOPT_FILE, $write_responsefile); #EXECUTE REQUEST my $retval = $ch->perform; close($write_responsefile); if ($retval){ return 0; }else{ return 1; } }