ShyykoSerhiy / skyweb

Unofficial Skype API for nodejs via 'Skype (HTTP)' protocol.
MIT License
193 stars 44 forks source link

adding contacts #48

Open SerRashin opened 8 years ago

SerRashin commented 8 years ago

hi diar friend, I write code for adding new contact

RequestService.prototype.add = function (skypeAccount, userName) {
        var reqURI = Consts.SKYPEWEB_HTTPS + Consts.SKYPEWEB_CONTACTS_HOST + '/contacts/v2/users/' + skypeAccount._selfInfo.username + '/contacts';

        this.requestWithJar.post(reqURI, {
            headers: {
                'Accept': 'application/json; ver=1.0',
                'Accept-Encoding': 'gzip, deflate, br',
                'Accept-Language': 'en-US,en;q=0.5',
                'Content-Type': 'application/json',
                'Host': 'contacts.skype.com',
                'Origin': 'https://web.skype.com',
                'Referer': 'https://web.skype.com/en/',
                'X-Skype-Caller': 'skype.com',
                'X-Skypetoken': skypeAccount.skypeToken
            },
            json: {
                greeting: "hi "+ userName + " add me please :)",
                mri: "8:"+userName
            }
        }, function (error, response, body) {
            if (!error && response.statusCode === 201) {
                return JSON.parse(body);
            } else {
                utils_1.default.throwError('Failed to accept friend.' + error + "/" + JSON.stringify(response));
            }
        });
    };
ShyykoSerhiy commented 8 years ago

Cheers @serhanters. I'll add it on this weekend. Thx. If you want you can open pull request 👍