Anything DIY

Promote your online product free of charge on Craigslist!

Post Reply
other / diy     Views: 427Prev .. Next
Promote your online product free of charge on Craigslist!Posted: Saturday, July 31, 2021 [14:54:30] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Selling your product on Craigslist could be challenging. The only allowed contacts are phone number and obfuscated email.
No Website URLs allowed.
Since most people prefer SMS contacts - SMS instant reply with URL will do the trick.

Promote your online product free of charge on Craigslist!

Steps:
1. Open new Gmail account and add Google Voice phone number to it.
2. Forward all SMS messages to your newly created Gmail.
3. Forward all calls to your existing phone number or install Google Voice App on your cell phone.
4. Create Gmail reading script on your local machine to grab incoming SMS messages and reply based on a keywords in a message with your Website URL.

Some programming knowledge required!

Now all SMS messages will be captured by your Gmail script and replied with link to your website or any other important information.

Next - a Perl script to capture SMS messages.There's no place like ~
Perl script to capture SMS messagesPosted: Saturday, July 31, 2021 [15:01:42] - 2
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Our weapon of choice is Perl. The same could be done in PHP, Python languages. You mileage may vary.

View Code#!/usr/bin/perl
use strict;
use warnings;
$ENV{'PATH'} = '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin';
my $localtime = `date`;chop $localtime;$localtime =~ tr/ //s;
my $dateu=time;
my $client='';
my $dir='/Your_Program_Folder';

## Replace fields below with information to fit your account
my $gmail_name='Joe Smith ';
my $just_user='your_user_account';
my $username = '[email protected]';
my $password = 'your_gmail_password';
my $keepfor=180; # DAYS
## Personal data end

my $removemes = $dateu - (86400 * $keepfor);
open(STDOUT,">$dir/last.result.txt");print "$localtime\n";
use Mail::IMAPClient;
use IO::Socket::SSL;
use MIME::Base64 ();
my $sock = IO::Socket::SSL->new(
PeerAddr => "imap.gmail.com",
PeerPort => 993) or die $@;
$client = Mail::IMAPClient->new(
Socket => $sock,
User => $username,
Password => $password
);

my $folders = $client->folders
or die "List folders error: ", $client->LastError, "\n";
print "Folders: @$folders\n";

$client->select('INBOX')
or die "Select 'INBOX' error: ", $client->LastError, "\n";
our %pbsearch=();if(-f "$dir/phonebook.txt") {eval {require "$dir/phonebook.txt"};}
our %donecalls=();if(-f "$dir/done.calls.txt") {eval {require "$dir/done.calls.txt"};}
our %replies=();if(-f "$dir/replies.txt") {eval {require "$dir/replies.txt"};}
my @messages = $client->messages;my $x='';my $numberofcalls=0;my %respond=();
@messages = reverse @messages;
foreach my $bs (@messages){
my $from = $client->get_header($bs,"from");
unless($from =~ m/txt\.voice\.google\.com/i) {$x--;next;}
my $date = $client->get_header($bs,"date");
my $subj = $client->get_header($bs,"subject");
my $message = $client->body_string( $bs );
my($mtext,$dtstamp,$toph,$frph,$clcode) = readmess($message,$date,$from);my $recdtime="$frph.$dtstamp";
if($donecalls{$recdtime}) {print "DONE already\t$from\t$date\n";$x--;next;} ## IF ALREADY DONE - SKIP
my $visphone='';
if(length($frph) == 11) {
$visphone=$frph;$visphone =~ s#(\d)(\d{3})(\d{3})(\d{4})#$1\($2\)$3\-$4#;
$donecalls{$recdtime}{phone_from}=$visphone;
}
$numberofcalls++;
$donecalls{$recdtime}{from}=$frph;
$donecalls{$recdtime}{from_email}=$from;
$donecalls{$recdtime}{to}=$toph;
$donecalls{$recdtime}{phonestamp}=$clcode;
$donecalls{$recdtime}{message}=$mtext;
$donecalls{$recdtime}{date}=$date;
$donecalls{$recdtime}{udate}=$dateu;
$donecalls{$recdtime}{subject}=$subj;
print "From: $from\nDate: $date\nSubject: $subj\nStamp: $dtstamp\nTo: $toph\nFrom Ph: $frph\nCode: $clcode\nMessage: $mtext\n\n";
if($pbsearch{$frph}) {$donecalls{$recdtime}{name}=$pbsearch{$frph};print "From Name: $pbsearch{$frph}\n";}
my $response='';
foreach my $k (keys(%replies)) {
if($mtext =~ m/\Q$k\E/i || $k =~ m/\Q$mtext\E/i) {$response = $replies{$k};print "Matched: $&\n";last;} ## FOUND RESPONCE
} ## FOREACH REPLY END

if($response) {print "---- Response required ----\n\n";
print "From: $donecalls{$recdtime}{from_email}\nResponse: $response\n";
$respond{$donecalls{$recdtime}{from_email}}{response}=$response;
$respond{$donecalls{$recdtime}{from_email}}{subject}=$donecalls{$recdtime}{subject};
$donecalls{$recdtime}{responded}=$response;
} ## END RESPONSE REQUIRED

} ## FOR END
$client->logout();

print "\nFinished login\nNumber of calls: $numberofcalls\n\n";

if($numberofcalls > 0) {
print "Number of calls received: $numberofcalls\n";
open(TXC,">$dir/done.calls.txt");my $comma='';print TXC "\%donecalls = (\n";
foreach my $t (sort keys(%donecalls)) {
if($donecalls{$t}{udate} < $removemes) {next;} ## REMOVE OLD MESSAGES
print TXC "$comma'$t' => {\n";$comma=",\n";my $comma1="\t";
foreach my $k (sort keys %{$donecalls{$t}}) {$donecalls{$t}{$k} =~ s/\'/\\\'/g;
print TXC "$comma1'$k','$donecalls{$t}{$k}'";$comma1 = ",\n\t";
} ## FOREACH KEY END
print TXC "\n\t}";
} ## FOREACH TIMESTAMP END
print TXC "\n);\n";close(TXC);
} ## END NEW CALLS FOUND

my $noresp = keys(%respond);
print "Number of responses: $noresp\n";
if($noresp > 0) {
print "\nSENDING RESPONSE\n";
use MIME::Entity;
use Net::SMTP;
use IO::Socket::SSL;
use Authen::SASL;

foreach my $to (keys (%respond)) {
my $subject = $respond{$to}{subject};
my $message = $respond{$to}{response};

print "Response Subject: $subject\nMessage: $message\n\n";

my $from = "$gmail_name<$username>";

my $mime = MIME::Entity->build(Type => 'multipart/alternative',
Encoding => '-SUGGEST',
From => $from,
To => $to,
Subject => $subject
);

$mime->attach(Type => 'text/plain',
Encoding =>'-SUGGEST',
Data => $message);
my $errors='';
my $smtp = Net::SMTP->new('smtp.gmail.com',
Port => 465,
SSL => 1,
Hello => "$just_user.local",
Timeout => 20
);
if($@) {print "ERROR: $@\n\n";$errors = "$@\n";}

my $sasl = Authen::SASL->new(
mechanism => 'GSSAPI',
callback => {
pass => $password,
user => $username,
}
);

eval {$smtp->auth( $sasl )};
if($@) {print "Authentication error: $@\n";$errors = "$@\n";}

if($errors) {$smtp->quit();&doerrors($errors);}

$smtp->mail($from);
$smtp->to($to);
$smtp->data($mime->stringify);
$smtp->quit();

} ## FOREACH TO EMAIL END
} ## END RESPOND TO SMS

sub readmess {
my ($m,$date,$from) = @_;$m =~ s/\r/\n/g;$m =~ tr/\n\n//s;my @ms=split(/\n/,$m);
my $spl = shift(@ms);
my @parts = split(/$spl/,$m);
shift(@parts);$m = shift(@parts);
$m =~ s#(.*?)\<(.*?)\>(.*)#$3#s;
if($m =~ m/text\/plain/ && $m =~ m/base64/) {
$m =~ s#(.*?)(base64)(.*)#$3#s;my $decoded = MIME::Base64::decode($m);$m=$decoded;
$m =~ s#(.*?)\<(.*?)\>(.*)#$3#s;
} ## END IF BASE64
my $notags = $m =~ s#<(.*?)>#$&#g;
if($notags > 10) {$m='';}
$m =~ s#(.*?)(YOUR ACCOUNT|To respond to this text message)(.*)#$1#s;
$m =~ s/^\s+//;$m =~ s/\s+$//;
#Sat, 19 Sep 2020 16:54:15 +0000$date =~ s#(\:)(\d{2})(\s)#$3#g;
$date =~ s/\,//g;$date =~ s/\:/ /g;$date =~ s/\d{4}$//;$date =~ s/\W+$//;$date =~ tr/ //s;
$date =~ s# #\.#g;
$from =~ s#(.*?)<(.*)>#$2#;
$from =~ s#(\d{11})\.(\d+)\.(.*?)(\@)(.*)##;
my $phfr=$2;my $phto=$1;my $code=$3;
return ($m,$date,$phto,$phfr,$code);
} # END SUB READ MESSAGE

sub doerrors {
my $err = shift;
my $sendmail = '/usr/sbin/sendmail -t -oi';
open(MAIL,"|$sendmail");
print MAIL <<EOM;
From: user\@domain.com
To: user_rcv\@domain.com
Subject: Eval Error found using Gmail SMS reply
\nWhile trying to send email VIA Gmail procedure error was found!
Reported by: check.gmail.cgi
Error: $err
EOM
close(MAIL);
exit(0);} ## END SUB DO ERRORS


Next - replies.txt file content.There's no place like ~
Replies.txt file contentPosted: Saturday, July 31, 2021 [15:09:39] - 3
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
For script to properly respond to different Craigslist ads keywords based on Ad content used in "replies.txt" file.
For example:
View Code%replies = (
'book','Books for sale:
https://www.Your_Site.com/for-sale/books/',
'chevrole','2005 Chevy Camaro for sale:
https://www.Your_Site.com/camaro-for-sale/',
'directio','Direction to us:
https://www.google.com/maps/dir//1.0602554,-5.2755837/@1.0602543,-5.2761792,19z/data=!2f7!4k1!1z9',
'genera','12000W generator for sale:
https://www.Your_Site.com/generator/'
);


Do not forget to test your program by sending SMS-es with keywords.There's no place like ~
Running script from CronPosted: Saturday, July 31, 2021 [15:25:08] - 4
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
SMS script has to be run periodically. It could be every 1 minute or every 5 minutes.
Easiest way to run it probably is a cron job by adding the line to /etc/crontab i.e.:
View Code*/5 * * * * your_user_account /usr/bin/perl /sms/check.gmail.cgi


it will run your program every 5 minutes.There's no place like ~
other / diyPrev .. Next
 
Post Reply
Home - Other: Anything DIY
Our Telegram Group