C
C
cancera2016-04-14 10:20:46
PHP
cancera, 2016-04-14 10:20:46

Why is a 503 error returned when authorizing through the Odnoklassniki API?

registered the application on Odnoklassniki, got an ID, used the php script from the OK site:
<?php
$AUTH['client_id'] = 'YOUR APP ID';
$AUTH['client_secret'] = 'YOUR APP SECRET';
$AUTH['application_key'] = 'YOUR APP KEY';
if (isset($_GET['code'])) {
$curl = curl_init(' api.odnoklassniki.ru/oauth/token.do ');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'code=' . $_GET['code'] . '&redirect_uri=' . urlencode($HOST . 'auth.php?name=odnoklassniki') . '&grant_type=authorization_code&client_id=' . $AUTH ['client_id'] .'&client_secret=' . $AUTH['client_secret']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$s = curl_exec($curl);
curl_close($curl);
$auth = json_decode($s, true);
$curl = curl_init(' api.odnoklassniki.ru/fb.do?access_token= ' . $auth['access_token'] . '&application_key=' . $AUTH['application_key'] . '&method=users.getCurrentUser&sig=' . md5('application_key=' . $AUTH['application_key'] . 'method=users.getCurrentUser' . md5($auth['access_token'] . $AUTH['client_secret'])));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$s = curl_exec($curl);
curl_close($curl);
$user = json_decode($s, true);
/*
The $user array contains the following fields:
birthday - date of birth of the user
gender - gender of the user
pic_1 - small photo
pic_2 - large photo
*/
/*
...
Write the received data to the database, set cookies
...
*/
header('Location: /'); // redirect to the main page after authorization
} else header('Location: www.odnoklassniki.ru/oauth/authorize?client_id= ' . $AUTH['client_id'] . '&scope=VALUABLE ACCESS&response_type=code&redirect_uri=' . urlencode($ HOST .'auth.php?name=odnoklassniki'));
Result:
I click on the link, the Odnoklassniki authorization window appears.
I log in with my account and I get a 503 error.
What could be wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question