本文整理匯總了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)
})