我查找了一些twitter的php库
我不明白,为什么:
$creds = $twitterObj->get('/account/verify_credentials.json');
$status = $twitterObj->post('/statuses/update.json', array('status' => 'This a simple test from twitter-async at ' . date('m-d-Y h:i:s')));
比
好$resultorsomething = $twitterObj->verifyCredentials();
$resultorsomething = $twitterObj->updateStatus('This a status');
$resultorsomething = $twitterObj->postMessage('This a message');
为什么我需要学习twitter地址和命令,而不是让IDE和代码完成为我做这些?
我不关心我需要使用什么方法来处理一些命令,POST或GET(即使它很明显),以及它在什么地址解决,我只想发布消息或获取令牌等。
——编辑:
我查看了python的tweepy库,我不擅长python,但正如我从这个文件中看到的- https://github.com/tweepy/tweepy/blob/master/tweepy/api.py它做的正是我所说的
""" statuses/update """
update_status = bind_api(
path = '/statuses/update.json',
method = 'POST',
payload_type = 'status',
allowed_param = ['status', 'in_reply_to_status_id', 'lat', 'long', 'source', 'place_id'],
require_auth = True
)
路径和方法被硬编码到方法中,我们需要的参数只有status, lat, long等
像updateStatus
这样的命令只是使用post
版本的包装器。如果包装器命令存在于你的框架中,那么你最好使用它们,因为如果post
命令要改变,那么你就不必改变自己的代码(希望如此)。