Chce zrobić logowanie na swojej stronie internetowej poprzez NK.PL. Potrzebuję pobrać adres email, imię z NK.
Mam następujący kod "w guziczku":
require 'nk/src/NK.php'; $conf = new NKConfig(); $conf->permissions = array(NKPermissions::BASIC_PROFILE,NKPermissions::EMAIL_PROFILE,NKPermissions::CREATE_SHOUTS); $conf->key = 'nazwa[rojektu-aaff8cd2-b150-42aa-87'; $conf->secret = 'xxxxxx-bc21-xxxx-a113-xxx0dxxxxx96'; $conf->callback_url = 'http://domena.pl/?login=nk'; $auth = new NKConnect($conf);
oraz weryfikację:
if ($_GET ['login'] == "nk") { $url = "https://nk.pl/oauth2/token"; "client_secret" => 'xxxxxx-bc21-xxxx-a113-xxx0dxxxxx96", "grant_type" => "authorization_code", "redirect_uri" => "http://domena.pl/?login=nk", "scope" => "BASIC_PROFILE_ROLE,EMAIL_PROFILE_ROLE,CREATE_SHOUTS_ROLE", "code" => $_GET['code'], ); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); $string = curl_exec($ch); curl_close($ch); $data = json_decode($string, true); if (false === isset($data['error'])) { echo"DZIALA<br>"; // insert into database } print_r($data) ; }
Niestety nie chce mi to działać i zwraca błąd:
Array ( [error] => invalid_grant [error_description] => Different redirect uri [error_uri] => http://developers.nk.pl/wiki/NKConnect_Errors )
Wie ktoś może co robię nie tak?
Bardzo proszę o pomoc,
Łukasz