phpnewb999 Posted August 9, 2007 Share Posted August 9, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/64126-php-curl/ Share on other sites More sharing options...
phpnewb999 Posted August 13, 2007 Author Share Posted August 13, 2007 anyone see anything wrong with this code? Quote Link to comment https://forums.phpfreaks.com/topic/64126-php-curl/#findComment-322506 Share on other sites More sharing options...
NArc0t1c Posted August 13, 2007 Share Posted August 13, 2007 That's not posting, It's just sending headers and getting the response. There is something else you need to post. Search for it on http://php.net/curl Quote Link to comment https://forums.phpfreaks.com/topic/64126-php-curl/#findComment-322594 Share on other sites More sharing options...
phpnewb999 Posted August 16, 2007 Author Share Posted August 16, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/64126-php-curl/#findComment-325887 Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 #!c:\perl\bin\perl.exe That's A Pearl script. Quote Link to comment https://forums.phpfreaks.com/topic/64126-php-curl/#findComment-325890 Share on other sites More sharing options...
phpnewb999 Posted August 16, 2007 Author Share Posted August 16, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/64126-php-curl/#findComment-325961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.