'; echo "-- Starting session\n"; if (empty($_SESSION['state'])) { $_SESSION['state'] = 0; } $state =& $_SESSION['state']; if ($state == 1 && empty($_GET['oauth_token'])) { $state = 0; } try { $oauth = new OAuth($conskey, $conssec, null, $oauth_type); $oauth->enableDebug(); $oauth->disableSSLChecks(); if (!isset($_GET['oauth_token']) && $state == 0) { try { $request_token_info = $oauth->getRequestToken($req_url, $from); } catch (OAuthException $e) { print_r($oauth); throw $e; } if (empty($request_token_info['oauth_token_secret'])) { print_r($oauth->debugInfo); print_r($request_token_info); throw new Exception("Empty token secret"); } $_SESSION['secret'] = $request_token_info['oauth_token_secret']; $_SESSION['state'] = 1; $url = $authurl."?oauth_token=".$request_token_info['oauth_token']; echo "INITIATE OK !\n"; echo "Cliquer ici : $url\n\n"; print_r($request_token_info); exit; } else if ($state == 1) { $oauth->setToken($_GET['oauth_token'], $_SESSION['secret']); $access_token_info = $oauth->getAccessToken($acc_url); $_SESSION['state'] = 2; $_SESSION['token'] = $access_token_info['oauth_token']; $_SESSION['secret'] = $access_token_info['oauth_token_secret']; $url = $from; echo "TOKEN OK !\n"; echo "Cliquer ici : $url\n\n"; print_r($access_token_info); exit; } elseif ($state == 2) { echo "API CALL !\n"; echo "Using token ".$_SESSION['token']." / ".$_SESSION['secret']."\n"; echo "Requesting API :\n\n"; $oauth->setToken($_SESSION['token'], $_SESSION['secret']); $api_url = $url . '/group/get_skin_data.json?id=19j'; $oauth->fetch($api_url); $json = json_decode($oauth->getLastResponse(), true); print_r($json); exit; $json = array( 'id' => '19j', 'lang' => ($json['lang'] == 'en') ? 'fr' : 'en', 'title' => 'WTF WTF WTF', 'description' => $json['description'] . ' ++ '.date('d:m:Y H:i:s'), 'public' => $json['public'] ? false : true, 'secret' => $json['secret'] ? false : true, 'wall_enabled' => $json['wall_enabled'] ? false : true, 'join_mode' => 'OPEN', 'invite_access' => 'MEMBER', 'member_access' => 'ADMIN', 'post_access' => 'USER', 'comment_access' => 'USER', 'valid_posts' => $json['valid_posts'] ? false : true, 'valid_comments' => $json['valid_comments'] ? false : true, //'skin_id' ); //$datas = $oauth->getLastResponse(); $datas = json_encode($json); $api_url = $url . '/group/set.json'; $oauth->fetch($api_url, $datas, OAUTH_HTTP_METHOD_POST, array('Content-Type' => 'application/json')); echo "OK\n"; var_dump(json_decode($oauth->getLastResponse(), true)); echo "\nRecommencer"; } } catch(OAuthException $E) { print_r($E); } ?>