Mishkat al-Masabih 1036
Ibn ‘Abbas told of a man coming to God’s Messenger and saying, “Messenger of God, it seemed to me last night when I was asleep as if I were praying behind a tree. I prostrated myself, the tree prostrating itself at the same time, and I heard it say, ‘O God, record a reward for me for it, remit from me a load for it, make it a treasure with Thee for me, and accept it from me as Thou didst accept it from Thy servant David’.” Ibn ‘Abbas said:
The Prophet thereupon recited a verse at which a prostration should be made, then prostrated himself, and I heard him saying the words the man told him the tree had said. 

Tirmidhi and Ibn Majah transmitted it, but Ibn Majah did not mention, "and accept it from me as Thou didst accept it from Thy servant David.” Tirmidhi said this is a gharib tradition.
وَعَنِ ابْنِ عَبَّاسٍ رَضِيَ اللَّهُ عَنْهُمَا قَالَ: جَاءَ رَجُلٌ إِلَى رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فَقَالَ: يَا رَسُولَ اللَّهِ رَأَيْتُنِي اللَّيْلَةَ وَأَنَا نَائِمٌ كَأَنِّي أُصَلِّي خَلْفَ شَجَرَةٍ فَسَجَدْتُ فَسَجَدَتِ الشَّجَرَةُ لِسُجُودِي فَسَمِعْتُهَا تَقُولُ: اللَّهُمَّ اكْتُبْ لِي بِهَا عِنْدَكَ أَجْرًا وَضَعْ عَنِّي بِهَا وِزْرًا وَاجْعَلْهَا لِي عِنْدَكَ ذُخْرًا وَتَقَبَّلْهَا مِنِّي كَمَا تَقَبَّلْتَهَا مِنْ عَبْدِكَ دَاوُدَ. قَالَ ابْنُ عَبَّاسٍ: فَقَرَأَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ سَجْدَةً ثُمَّ سَجَدَ فَسَمِعْتُهُ وَهُوَ يَقُولُ مِثْلَ مَا أَخْبَرَهُ الرَّجُلُ عَنْ قَوْلِ الشَّجَرَةِ. رَوَاهُ التِّرْمِذِيُّ وَابْنُ مَاجَهْ إِلَّا أَنَّهُ لَمْ يَذْكُرْ وَتَقَبَّلْهَا مِنِّي كَمَا تَقَبَّلْتَهَا مِنْ عَبْدِكَ دَاوُدَ. وَقَالَ التِّرْمِذِيُّ: هَذَا حَدِيثٌ غَرِيبٌ