我正在开发一个APP,我希望用户点击一个按钮并向其时间轴发送一条推文。有几种使用Node.JS和Angular做到这一点的已知方法,但是我正在寻找一种解决方案,以在不运行Node Server的情况下实现我想要的功能。
有没有一种方法可以将Twitter API嵌入您的IONIC / Angular APP。而且我没有在寻找Ionic插件TwitterConnect,因为它没有POST方法。
这是twitter示例,但是我将如何在Angular中实现呢?
curl -XPOST
--url 'https://api.twitter.com/1.1/statuses/update.json?status=hello'
--header 'authorization: OAuth
oauth_consumer_key="oauth_customer_key",
oauth_nonce="generated_oauth_nonce",
oauth_signature="generated_oauth_signature",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="generated_timestamp",
oauth_token="oauth_token",
oauth_version="1.0"'
Run Code Online (Sandbox Code Playgroud)
这是 @GonzaloNicolás建议的链接https://developer.twitter.com/zh-CN/docs/tweets/post-and-engage/api-reference/post-statuses-update有人可以协助我提供文档或一些编码示例。
我有一个正在运行的节点服务器。然后将其发送到Twitter时间轴,我有一个Ionic / Angular应用程序,消耗了节点服务器并发送了消息。
但是,问题在于,在节点服务器中,我的用户的Twitter帐户信息是硬编码的,我想知道如何发送从Twitter Connect插件获得的用户详细信息。
这是我的节点服务器
const express = require('express');
const Twitter = require('twit');
const app = express();
const client = new Twitter({
consumer_key: '...',
consumer_secret: '...',
access_token: '...',
access_token_secret: '...',
});
app.use(require('cors')());
app.use(require('body-parser').json());
app.post('/post_tweet', (req, res) => {
tweet = req.body;
client
.post(`statuses/update`, tweet)
.then(tweeting => {
console.log(tweeting);
res.send(tweeting);
})
.catch(error => {
res.send(error);
});
});
app.listen(3000, () => console.log('Server running'));
Run Code Online (Sandbox Code Playgroud)
我的角度/离子应用程序中的twitter服务
export class TwitterserviceService {
api_url = 'http://localhost:3000';
constructor(private http: HttpClient) { }
tweet(tweetdata: string) {
return this.http.post<any>(`${this.api_url}/post_tweet/`, …Run Code Online (Sandbox Code Playgroud) 我正在为一家公司开发应用程序,该公司有几辆公共汽车和有轨电车在不同的路线/线路上行驶,并将游客运送到各个酒庄。
无论如何,我最初为驱动程序设计了该应用程序,以便使用电子邮件和密码登录Firebase数据库。
但是,系统使驱动程序及其笨拙等混乱。因此,我想通过单击按钮来使登录系统自动化。
这就是我到目前为止所拥有的。
登录系统
public class DriverLoginActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
private EditText mEmail, mPassword;
private Button mLogin, mRegistration, mRegisterDriver,mBackBtn;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener firebaseAuthListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_driver_login);
mBackBtn = findViewById(R.id.back_login_btn);
mBackBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DriverLoginActivity.this,MainActivity.class);
startActivity(intent);
finish();
}
});
mRegistration= (Button) findViewById(R.id.btn_reg);
mRegistration.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DriverLoginActivity.this, BusRegistrationActivity.class);
startActivity(intent);
finish();
return;
}
}); …Run Code Online (Sandbox Code Playgroud)