J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 800 forks source link

buildOauth is not necessary #76

Closed fulldecent closed 9 years ago

fulldecent commented 10 years ago

Is Oauth not required for every request? If this functionality be moved into performRequest to reduce verbosity.

$twitter = new TwitterAPIExchange($settings);
echo $twitter->buildOauth($url, $requestMethod)
             ->setPostfields($postfields)
             ->performRequest();

$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
             ->buildOauth($url, $requestMethod)
             ->performRequest();
ryunp commented 10 years ago

I do agree with this notion, is it really necessary to have the GET and POST methodologies differ with such mutually exclusivity? I'll admit to not scouring over the class to find explicit reasoning, but initial thoughts do agree with fulldecent.

As far as the Oauth process goes: There may be value to having another step, getBearerToken(), available to the dev for locally caching. I suppose having it always re-Oauth in case of invalidation is nice and possibly blanket functionalities having to check for any invalidation's along the way. An extra request is the trade off for less complexity, and with today's tech I doubt an extra request would matter unless capping out on access limitations.

As a relatively new programmer I may be overlooking some things, but just adding to conversation!

J7mbo commented 9 years ago

I agree, there doesn't need to be exclusivity... but the initial design decision involved being able to pass a string for the get field, and an array for the post field. Unfortunately, it sucks, but these now must stay for backward compatibility reasons...