Open edmondchuc opened 5 years ago
Looks like MacOS has some sort of protections on the ~/Library/Messages
directory that prevent command line programs from being able to access it– looks like the same sort of thing happens if you try to run ls ~/Library/Messages
(even with sudo
).
I didn't look too much into why this is the case, but if you're looking for a quick workaround, open up the messages folder with Finder:
$ open ~/Library/Messages
then copy the chat.db
file onto your desktop. You can then open include.php
and change the first line to this:
$db = new PDO('sqlite:' . $_SERVER['HOME'] . '/Desktop/chat.db');
and that should fix it!
I was able to fix this on macOS Catalina without copying the chat.db
file by going into System Preferences > Security > Privacy > Full Disk Access and enabling my terminal which I used to run php contacts.php
(which had previously thrown the same error OP mentioned). I was using the default macOS Terminal app.
When I run
php contacts.php
I get