Author Topic: [API] sendPM  (Read 592 times)

0 Members and 0 Guests are viewing this topic.

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
[API] sendPM
« on: June 05, 2014, 12:40:58 am »
For coders only!


This code utilizes jQuery, please use the latest version found in this thread: http://support.createaforum.com/5/jquery-v1-8-update/

Code: [Select]
"use strict";function sendPM(n,t,i,r){var u,f;return $.ajax({url:smf_scripturl+"?action=pm;sa=send",type:"GET",async:!1}).done(function(n){u=$(n).find("input[name='seqnum']").attr("value")}).fail(function(){return console.log("SendPM: Error when retrieving the sequence number"),!1}),f="to="+n+"&bcc="+t+"&subject="+encodeURIComponent(i)+"&sel_face=&sel_size=&sel_color=&message="+encodeURIComponent(r)+"&message_mode=0&f5c47df6060e=9ff02ff520d1924481c3bf9c526aa00a&seqnum="+u+"&replied_to=0&pm_head=0&f=inbox&l=-1&to="+n+"&bcc="+t,$.ajax({url:smf_scripturl+"?action=pm;sa=send2",type:"POST",data:f}).done(function(){console.log("SendPM: Sent PM to "+n)}).fail(function(){return console.log("SendPM: Error when sending PM"),!1}),!0}

Usage:
Code: [Select]
sendPM(recipient, bcc, subject, message);
« Last Edit: June 06, 2014, 05:29:17 pm by aIURbliS »
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Share on Facebook Share on Twitter


Offline CreateAForum

  • Administrator
  • *****
  • Posts: 5733
  • Karma: 276
    • View Profile
Re: [API] sendPM
« Reply #1 on: June 05, 2014, 12:49:20 pm »
Looks neat
Like Create A Forum? Support me at https://www.patreon.com/vbgamer45/

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [API] sendPM
« Reply #2 on: June 05, 2014, 10:27:26 pm »
Looks neat
Hey would you mind telling me the purpose of this sequence number and how it is generated? The code makes a GET request solely for the sequence number which is pretty overkill

All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.