SSI sendpm

Started by anonymous001, August 15, 2015, 09:38:13 AM

Previous topic - Next topic

anonymous001

I'm using the following to to autosend a PM on some events from my external application.
While testing this code at the moment, just a white page is shown, no error message.
Any idea what's incorrect in my code?
I used this documentation:
http://support.simplemachines.org/function_db/index.php?action=view_function;id=315

I created an user account (id=2, username=tester) and now I try to send a pm from the user to the admin account (id=1).

code:
<?php

require_once('SSI.php');

require_once(
'Sources/Subs-Post.php');

        
$recipients = array(
                
'to' => array(1),
                
'bcc' => array(1)
        );

        
$from = array(
                
'id' => 2,
                
'name' => 'tester',
                
'sender' => 'tester'
        
);

        
sendpm($recipients'the subject''the body, without run through preparsecode'FALSE$from);

echo 'The PM was successfully sent.';

?>


cheers;

Shambles

Code (find) Select
'sender' => 'Sender')

Code (replace) Select
'sender' => 'Sender',

anonymous001

I don't understand what you are trying to tell me, please check code above, I edited a bit.

Illori

you have an extra closing ) on each sender line, it needs to be removed.

anonymous001

I edited code above.
Now my code seems to be runned (free of PHP errors). I get an SMF error, but the ids are correct, any idea how to fix?
Error:


Screen of users (from phpmyadmin):


Regards;

Shambles

Quote from: jaheller on August 15, 2015, 09:57:31 AM
I don't understand what you are trying to tell me, please check code above, I edited a bit.

You edited your post such that my solution no longer appears valid. That was just plain daft.

anonymous001

Your solution helped me, now my code is free of "php" errors, but please check code in first post and my post before this one here, a new error occurs, now SMF based.

live627

Code (find) Select
'sender' => 'Sender')

Code (replace) Select
'username' => 'Sender',

anonymous001

Thanks a lot friends, sadly I cant edit my first post anymore. Please check my post with pictures (in this thread). I've got a new SMF based error and no idea how to fix it, all I checked was correct.

Shambles

Quote from: jaheller on August 15, 2015, 11:03:22 AM
Thanks a lot friends, sadly I cant edit my first post anymore.

That's my point. Don't keep going back and altering the evidence - use the thread to expand on your issue.

Now, show us exactly what you currently have in your source file.

anonymous001

#10
I tried to send a message from "tester" (user id=2) to "admin" (user id=1).
Actual code:

<?php

require_once('SSI.php');

require_once(
'Sources/Subs-Post.php');

        
$recipients = array(
                
'to' => array(1),
                
'bcc' => array(1)
        );

        
$from = array(
                
'id' => 2,
                
'name' => 'tester',
                
'sender' => 'tester',
        );

        
sendpm($recipients'the subject''the body, without run through preparsecode'FALSE$from);

echo 'The PM was successfully sent.';

?>


Now my code seems to be runned (free of PHP errors). I get an SMF error, but the ids are correct, any idea how to fix?
Error:


Screen of users (from phpmyadmin):


Regards;


anonymous001

I edited code above, now it should be correct, same error as I show on the pictures :-\.

Shambles

So what does your code look like now? And please stop editing your previous posts - I for one do not like to go back and reread posts to see what's changed.

anonymous001

I tried to send a message from "tester" (user id=2) to "admin" (user id=1).
Actual code:

<?php

require_once('SSI.php');

require_once(
'Sources/Subs-Post.php');

        
$recipients = array(
                
'to' => array(1),
                
'bcc' => array(1)
        );

        
$from = array(
                
'id' => 2,
                
'name' => 'tester',
                
'sender' => 'tester',
        );

        
sendpm($recipients'the subject''the body, without run through preparsecode'FALSE$from);

echo 'The PM was successfully sent.';

?>


Now my code seems to be runned (free of PHP errors). I get an SMF error, but the ids are correct, any idea how to fix?
Error:


Screen of users (from phpmyadmin):


Regards;

Shambles

There's no such key named "sender" in the $from array, as live627 showed you earlier.



anonymous001

Ahh now it works, thanks a lot friend! ;)

Advertisement: