本文整理汇总了TypeScript中twit.post函数的典型用法代码示例。如果您正苦于以下问题:TypeScript post函数的具体用法?TypeScript post怎么用?TypeScript post使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: post
post(path: string, params: Object, cb: (ret: any) => void) {
this.client.post(path, params, (err, ret, res) => {
if (err) {
this.sendApiFailure(err, res);
return;
}
cb(ret);
});
}
示例2: tweet
public tweet(message: string) {
var message = '@' + this._atUser + ' ' + message;
message = message.substr(0, 140);
this._twit.post('statuses/update', { status: message }, (err, data, response) => {
if (!err) {
console.log('Message tweeted @' + this._atUser);
} else {
console.log(err);
}
});
}
示例3: tweetImage
export default async function tweetImage(logger: Logger) {
try {
const { fileName, file } = await getRandomPicture();
const b64Picture = file.toString('base64');
const uploadedPicture = await t.post('media/upload', {
stringify_ids: true,
media_data: b64Picture,
});
const mediaParams = {
stringify_ids: true,
// @ts-ignore
media_id: uploadedPicture.data.media_id_string,
alt_text,
};
await t.post('media/metadata/create', mediaParams);
const tweet = await t.post('statuses/update', {
stringify_ids: true,
status: config.twitter.tweetMessage,
// @ts-ignore
media_ids: [uploadedPicture.data.media_id_string],
});
logger.info({
status: config.twitter.tweetMessage,
// @ts-ignore
mediaIds: uploadedPicture.data.media_id_string,
image: fileName,
// @ts-ignore
tweet: tweet.data.id_str,
});
} catch (e) {
logger.error(e);
}
}
示例4: updateStatus
updateStatus(text: string, in_reply_to?: string) {
const params = {
status: text,
in_reply_to_status_id: undefined as string,
trim_user: false,
};
if (in_reply_to) {
params.in_reply_to_status_id = in_reply_to;
}
this.client.post('statuses/update', params, (err, tweet, res) => {
if (err) {
this.sendApiFailure(err, res);
return;
}
this.sender.send('yf:update-status-success', tweet);
log.debug('Status update success:', tweet.id);
});
}
示例5: Twit
import * as Twit from 'twit';
const t = new Twit( {
consumer_key: '',
consumer_secret: '',
app_only_auth: true,
} );
t.post('statuses/update', { status: 'hello!' }).then(res => {
const status = res.data as Twit.Twitter.Status
console.log(status.id_str)
console.log(res.resp.statusCode)
})