bitly-api-php icon indicating copy to clipboard operation
bitly-api-php copied to clipboard

construct function without parameters obliterates pre-set clientId, clientSecret and accessToken

Open pinzler opened this issue 12 years ago • 2 comments

The construct function defaults the parameters clientId, clientSecret and accessToken to null so doing this:

$btlObj = new Bitly;

... wipes out any pre-set keys/tokens. There probably is a much cleaner way too fix this (hence why I'm doing this as an issue and not a pull request) but I did quickly this way for the user who needed help:

public function __construct($clientId=null, $clientSecret=null, $accessToken=null) {

    if ($clientId!==null)
        $this->clientId = $clientId;
    if ($clientSecret!==null)
        $this->clientSecret = $clientSecret;
    if ($accessToken!==null)
        $this->accessToken = $accessToken;

    $this->userAgent = 'PHP/' . phpversion() . ' bitly_api/0.1.0';

}

pinzler avatar Oct 10 '13 16:10 pinzler

If you are constructing a new object what would the pre-existing properties be and where could they possibly have come from?

beeradmoore avatar Jun 02 '17 08:06 beeradmoore

Our lib is for Bitly Api v4. https://github.com/phplicengine/bitly

phplicengine avatar Nov 03 '19 06:11 phplicengine