Jump to content

phpnewb999

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phpnewb999's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes that is a perl script that works fine. Basically I've been trying to convert it into a php script using curl but to no success.
  2. I've read and tried everything but it is just working in php. It seems to be that the username and password is just not being passed. Below is a perl script that works: #!c:\perl\bin\perl.exe # ^^^ this must be the first line of the script! ^^^ # start code use strict; use CGI; my $q = new CGI; # print header and start the markup output print $q->header( "text/html" ),$q->start_html( "backpage response" ); # end code use Getopt::Long; use LWP::UserAgent; use HTTP::Request::Common; my $server = 'newyork.backpage.com'; # You may choose to hard-code $email and $password here instead my $email = 'bpsales'; my $password = 'bpoffice'; my $filename = 'backpage.xml'; my $ua = LWP::UserAgent->new(); $ua->agent(qq|Backpage Form Upload Client ($email)|); my @parameters = ( email => $email, password => $password, importFile => [ $filename ], quiet => 'yes' ); my $url = "http://posting.$server/online/BulkUpload/PostAds"; my $req = POST($url, Content_Type => 'form-data', Content => \@parameters ); # $req->content_type('multipart/form-data'); my $response = $ua->request($req); if ($response->is_success()) { my $output = $response->content(); $output =~ s/^[\s\.]+//; # remove leading whitespace and marching dots print $output; } else { print "HTTP request failed:\n"; print $response->status_line() . "\n"; exit 1; } Again anyone see whats missing/wrong with the php script?
  3. anyone see anything wrong with this code?
  4. Hi All, I wrote this code with php curl to do a http post feed to backpage: $url = "http://posting.newyork.backpage.com/online/BulkUpload/PostAds"; $filename = "mai_backpage.xml"; $handle = fopen($filename, "r"); $request = fread($handle, filesize($filename)); $header[] = "Content-type: application/x-www-form-urlencoded"; $header[] = "Accept: text/xml"; $header[] = "Content-length: ".strlen($request); $header[] = "Cache-Control: no-cache"; $header[] = "Connection: close \r\n"; $header[] = $request; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERPWD, user@email.com:password'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); $execPost = curl_exec($ch); curl_close($ch); echo"$execPost"; $closefile = fclose($handle); and I've been getting this for reply <?xml version="1.0" encoding="ISO-8859-1" ?> - <importResults> <userKey /> <newAdCount>0</newAdCount> <updatedAdCount>0</updatedAdCount> <creditsUsed>0</creditsUsed> <importError>Missing email.</importError> <importError>Missing password.</importError> <importError>Authentication failed.</importError> <importError>Missing file.</importError> </importResults> What am I doing wrong that they are not reading the email and password for authentication? Here is the upload documentation from backpage: http://newyork.backpage.com/online/bulkupload/Documentation Thanks in Advance!
  5. Yes i understand.  The windows machine i have the smtp set to 10.10.10.68 which is the mail server and everything works fine but for the linux machine.  What would i have to set the path to? 
  6. What would i need to change in the php.ini file to make the mail() function to work on a linux machine?  So far the windows server mail() function works fine after entering the "10.10.10.68". [mail function] ; For Win32 only. SMTP = 10.10.10.68 ; For Win32 only. sendmail_from = ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = Thanks in Advance
  7. I was wondering if it was possible to partially fill out forms by clicking on a link? Example: www.form.com contains a form with (have no access to modify the page codes) <select name="element">     <option>none</option>     <option>apple</option>     <option>orange</option>     <option>grape</option> </select> Now, i would like to make a page on my site where i have a link <a href="http://www.form.com">click here</a> Would it be possible that when someone clicks on my page it will have the select element (apple) selected?
  8. I have a form with a textarea.  On submission of the form, everything within the textarea would be echoed on the next page.  The only thing is that everything that is echoed out is in one continuous line.  I want it so that when someone presses enter, there would be a break.  Something like this form when starting a new topic or replying.  Where i can hit enter and when displayed on the forum, it is on a new line.  What i have done so far is onkeydown event call to check if the enter key is hit, if so do obj.value += '<br>'.  What this does is add <br> at the end of the textarea.  How can i get it so that <br> will not appear and also be placed anywhere in the textarea when entered is hit. Thanks in advance.
  9. I finally got the Curl extension installed and wrote a little code (which of course is not working :( ) [code] $fp = fopen("sample.xml", "r") $url = "https://mysite.com" $ch = curl_init() curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded")) curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)   curl_setopt($ch, CURLOPT_UPLOAD, 1)   curl_setopt($ch, CURLOPT_INFILE, $fp)   $result = curl_exec($ch) curl_close ($ch) print $result [/code] What i need to do is establish a https connection, send a http request with content of "application/x-www-form-urlencoded" containing the sample.xml content. Any help as to what i'm doing wrong pls. Thanks
  10. Is there a way to establish a https connection with php that is similar to the code below which is written in perl? #!/usr/bin/perl use LWP; use LWP::UserAgent; use Getopt::Std; use strict; use constant BASE_URL => 'https://post.mysite.org/bulk; # process options my $opts = {}; getopts('o:f:p', $opts); my $post = $opts->{'p'}; my $filename = $opts->{'f'}; my $outfile = $opts->{'o'}; unless($filename) { print "usage: $0 [-p] [-o outfile] -f filename\n". " options:\n". " -f - the name of the RSS file to submit (required)\n". " -p - actually post (otherwise just validate)\n". " -o - output filename (otherwise results sent to STDOUT)\n\n"; exit(0); } # open file my $content = undef; open(CFH, "<$filename") || die "can't open $filename for read: $!"; { local $/ = undef; $content = <CFH>; } close(CFH); # prepare request my $ua = LWP::UserAgent->new(); $ua->agent('SampleBulkPostClient/0.1'); my $post_url = BASE_URL .'/'. ($post? 'post': 'validate'); my $req = HTTP::Request->new( POST => $post_url ); $req->content_type('application/x-www-form-urlencoded'); $req->content($content); # issue request my $res = $ua->request($req); # print result if($res->is_success()) { if($outfile) { open(OFH,">$outfile") || die "can't open $outfile for write: $!"; print OFH $res->content(); close OFH; } else { print $res->content()."\n"; } } else { print "request failed:\n". $res->status_line()."\n".$res->content()."\n"; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.