jsocol / bitly-api-php

Other
16 stars 20 forks source link

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

Open pinzler opened 11 years ago

pinzler commented 11 years ago

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';

}
beeradmoore commented 7 years ago

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

phplicengine commented 4 years ago

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