I’m working on a system to be able to auto-accept certain friend requests. I will try migrating it to a mail rule asap and adding comment replies etcetera as part of a massive AI project I’m working on. Here’s my problem: the facebook accept request button does not return anything or accept the request when I curl the attached link as it should. What am i doing wrong?
Here is the code to get the link, feel free to poke it with a stick and improve it.
tell application "Mail"
set theMessages to every message of message viewer 1
set titles to subject of every message of message viewer 1
set option to (choose from list titles)
repeat with i from 1 to (the number of items in theMessages)
if option as text is (item i of titles) as text then
set thisMessage to item i of theMessages
exit repeat
end if
end repeat
set thisMessageSource to source of thisMessage as text
end tell
set thisMessageSource to removeEqualsRet(thisMessageSource)
set search1 to (offset of "Confirm friend request" in thisMessageSource) - 350
set clamp to (characters search1 through (search1 + 350) of thisMessageSource) as string
set search2 to (offset of "http://www.facebook.com" in clamp)
set clamp to (characters search2 through -1 of clamp) as string
set search3 to (offset of "\"" in clamp) - 1
set confirmLink to linkFix(characters 1 through search3 of clamp as string)
do shell script ("curl \"" & confirmLink & "\"")
return confirmLink
(* Here I add functions to turn mail's source garbage into a html link.*)
on removeEqualsRet(input)
set output to ""
repeat with i from 1 to (the number of paragraphs in input)
try
if character -1 of paragraph i of input is "=" then
set output to output & characters 1 thru -2 of paragraph i of input as text
else
set output to output & paragraph i of input as text
end if
on error e
set output to output & paragraph i of input as text
end try
end repeat
return output
end removeEqualsRet
on linkFix(input)
set output to ""
repeat 20 times
set amper to offset of "&" in input
if amper is 0 then
set input to output & input
set output to ""
exit repeat
else
set output to output & characters 1 thru amper of input as text
set input to characters (amper + 5) thru -1 of input as text
end if
end repeat
repeat 20 times
set equi to offset of "=3D" in input
if equi is 0 then
set input to output & input
exit repeat
else
set output to output & characters 1 thru equi of input as text
set input to characters (equi + 3) thru -1 of input as text
end if
end repeat
return input as text
end linkFix