예제 #1
0
 public function testGetSignature()
 {
     $Class = new ReflectionClass(Client::class);
     $Method = $Class->getMethod('getSignature');
     $Method->setAccessible(true);
     $Token = new Token();
     $Token->setAccessToken('accesssss_tokkken');
     $Client = new Client();
     $Client->setToken($Token)->setClientSecret('ClienTSECRET');
     $this->assertEquals('01a36a2aa93eb052cbabc18febbaa992', $Method->invoke($Client, ['bbb' => 'opka', 'aaa' => 7]));
 }
예제 #2
0
$Command = new CommandPosix();
$Command->appendHelpParameter('show help');
$Command->appendParameter(new Option('client', 'c', 'client id', Option::TYPE_STRING, true), function ($name, $value) use(&$clientId) {
    $clientId = $value;
});
$Command->appendParameter(new Option('data', 'd', 'API method parameters (JSON)', Option::TYPE_STRING, true), function ($name, $value) use(&$methodData) {
    $methodData = json_decode($value, true);
});
$Command->appendParameter(new Option('key', 'k', 'application key', Option::TYPE_STRING, true), function ($name, $value) use(&$applicationKey) {
    $applicationKey = $value;
});
$Command->appendParameter(new Option('method', 'm', 'API method name', Option::TYPE_STRING, true), function ($name, $value) use(&$methodName) {
    $methodName = $value;
});
$Command->appendParameter(new Option('secret', 's', 'client secret', Option::TYPE_STRING, true), function ($name, $value) use(&$clientSecret) {
    $clientSecret = $value;
});
$Command->appendParameter(new Option('token', 't', 'access token', Option::TYPE_STRING, true), function ($name, $value) use(&$accessToken) {
    $accessToken = $value;
});
try {
    $Command->parse(true);
    $Token = new Token();
    $Token->setAccessToken($accessToken)->setTokenType(Token::TYPE_SESSION);
    $Client = new Client();
    $Client->setApplicationKey($applicationKey)->setToken($Token)->setClientId($clientId)->setClientSecret($clientSecret);
    $Result = $Client->call($methodName, $methodData);
    print_r($Result);
} catch (RequiredOptionException $Ex) {
    $Command->displayHelp();
}
/**
 * Copyright 2015 Alexey Maslov <*****@*****.**>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Odnoklassniki API method users.getCurrentUser example
 * @author alxmsl
 * @date 8/13/13
 */
include '../vendor/autoload.php';
use alxmsl\Odnoklassniki\OAuth2\Response\Token;
use alxmsl\Odnoklassniki\API\Client;
// Create authorization token instance
$Token = new Token();
$Token->setAccessToken('4cCE5s_T0KEn')->setRefreshToken('ReFRE5H_t0Ken')->setTokenType(Token::TYPE_SESSION);
// Create and initialize OK API client instance
$Client = new Client();
$Client->setApplicationKey('4Pp1IC4t10n_KEy')->setToken($Token)->setClientId(1234567890)->setClientSecret('C11eNt_SEcREt');
// Get current user info
$Result = $Client->call('users.getCurrentUser');
print_r($Result);
/**
 * Copyright 2015 Alexey Maslov <*****@*****.**>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Odnoklassniki API method users.getInfo example
 * @author alxmsl
 * @date 8/13/13
 */
include '../vendor/autoload.php';
use alxmsl\Odnoklassniki\OAuth2\Response\Token;
use alxmsl\Odnoklassniki\API\Client;
// Create authorization token instance
$Token = new Token();
$Token->setAccessToken('4cCE5s_T0KEn')->setRefreshToken('ReFRE5H_t0Ken')->setTokenType(Token::TYPE_SESSION);
// Create and initialize OK API client instance
$Client = new Client();
$Client->setApplicationKey('4Pp1IC4t10n_KEy')->setToken($Token)->setClientId(1234567890)->setClientSecret('C11eNt_SEcREt');
// Get current user big size avatar
$Result = $Client->callConfidence('users.getInfo', array('uids' => 1, 'fields' => 'pic_4'));
print_r($Result);