Can't switch instance from v1 to v2
adiv-phpian opened this issue · 8 comments
adiv-phpian commented
Call to undefined method Atymic\Twitter\ApiV1\Service\Twitter::forApiV2()
I tried to get version 2 instance from version 1, but it's returning error.
reliq commented
Thanks for reporting this @adiv-phpian. This issue should be resolved.
Cosnavel commented
The error with the undefined method is gone. But you can't instantiate the two clients. Look at this snippet:
$twitterV1 = Twitter::forApiV1()->usingCredentials($token, $tokenSecret, env('TWITTER_CONSUMER_KEY'), env('TWITTER_CONSUMER_SECRET'));
$twitterV2 = Twitter::forApiV2()->usingCredentials($token, $tokenSecret, env('TWITTER_CONSUMER_KEY'), env('TWITTER_CONSUMER_SECRET'));
dump($twitterV1);
dd($twitterV2);
Response:
Atymic\Twitter\Service\Accessor {#1450 ▼
-querier: Atymic\Twitter\Service\Querier {#1537 ▼
-config: Atymic\Twitter\Configuration {#1536 ▼
#apiUrl: "api.twitter.com"
#uploadUrl: "upload.twitter.com"
#apiVersion: "2"
#consumerKey: "*"
#consumerSecret: "*"
#accessToken: "*"
#accessTokenSecret: "*"
#debugMode: true
#userAgent: "atymic/twitter v3.x-dev php v8.0.0"
-authenticateUrl: "https://api.twitter.com/oauth/authenticate"
-accessTokenUrl: "https://api.twitter.com/oauth/access_token"
-requestTokenUrl: "https://api.twitter.com/oauth/request_token"
}
-clientFactory: Atymic\Twitter\Http\Factory\ClientCreator {#1432 ▶}
-syncClient: Atymic\Twitter\Http\Client\SyncClient {#1576 ▶}
-asyncClient: Atymic\Twitter\Http\Client\AsyncClient {#1538 ▶}
-logger: null
}
}
Atymic\Twitter\Service\Accessor {#1450 ▼
-querier: Atymic\Twitter\Service\Querier {#1537 ▼
-config: Atymic\Twitter\Configuration {#1536 ▼
#apiUrl: "api.twitter.com"
#uploadUrl: "upload.twitter.com"
#apiVersion: "2"
#consumerKey: "*"
#consumerSecret: "*"
#accessToken: "*"
#accessTokenSecret: "*"
#debugMode: true
#userAgent: "atymic/twitter v3.x-dev php v8.0.0"
-authenticateUrl: "https://api.twitter.com/oauth/authenticate"
-accessTokenUrl: "https://api.twitter.com/oauth/access_token"
-requestTokenUrl: "https://api.twitter.com/oauth/request_token"
}
-clientFactory: Atymic\Twitter\Http\Factory\ClientCreator {#1432 ▶}
-syncClient: Atymic\Twitter\Http\Client\SyncClient {#1576 ▶}
-asyncClient: Atymic\Twitter\Http\Client\AsyncClient {#1538 ▶}
-logger: null
}
Both of them are API Version 2.
Cosnavel commented
Before you have fixed the Method issue I have tried to fix this by updating the version directly in the config and then tried to get an instance of the other API version. This works neither well.
config(['twitter.api_version' => '1.1']);
$twitterV1 = Twitter::usingCredentials($token, $tokenSecret, env('TWITTER_CONSUMER_KEY'), env('TWITTER_CONSUMER_SECRET'));
config(['twitter.api_version' => '2']);
$twitterV2 = Twitter::usingCredentials($token, $tokenSecret, env('TWITTER_CONSUMER_KEY'), env('TWITTER_CONSUMER_SECRET'));
dump($twitterV1);
dd($twitterV2);
Response:
Atymic\Twitter\ApiV1\Service\Twitter {#1450 ▼
#config: Atymic\Twitter\Configuration {#1536 ▼
#apiUrl: "api.twitter.com"
#uploadUrl: "upload.twitter.com"
#apiVersion: "1.1"
#consumerKey: "*"
#consumerSecret: "*"
#accessToken: "*"
#accessTokenSecret: "*"
#debugMode: true
#userAgent: "atymic/twitter v3.x-dev php v8.0.0"
-authenticateUrl: "https://api.twitter.com/oauth/authenticate"
-accessTokenUrl: "https://api.twitter.com/oauth/access_token"
-requestTokenUrl: "https://api.twitter.com/oauth/request_token"
}
#querier: Atymic\Twitter\Service\Querier {#1538 ▶}
#debug: true
}
Atymic\Twitter\ApiV1\Service\Twitter {#1450 ▼
#config: Atymic\Twitter\Configuration {#1536 ▼
#apiUrl: "api.twitter.com"
#uploadUrl: "upload.twitter.com"
#apiVersion: "1.1"
#consumerKey: "*"
#consumerSecret: "*"
#accessToken: "*"
#accessTokenSecret: "*"
#debugMode: true
#userAgent: "atymic/twitter v3.x-dev php v8.0.0"
-authenticateUrl: "https://api.twitter.com/oauth/authenticate"
-accessTokenUrl: "https://api.twitter.com/oauth/access_token"
-requestTokenUrl: "https://api.twitter.com/oauth/request_token"
}
#querier: Atymic\Twitter\Service\Querier {#1538 ▶}
#debug: true
}
As far as I have gotten into this, the Configuration does not change. Probably this is a separate issue.
reliq commented