Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. $subdomain="amestrov";
  2.     $client_id="LworutTiRfoYZLpbE4B9aQ";
  3.     $client_secret="pn2bgiu2l5B-qHIx6NAPdiNDOxlKXndDZJRoRXfpDYw1kmqNLp8LYk341sy3VxPQtHvndpbdf6wRAqJ3ztvG8g";
  4.     $redirect_uri="http%3A%2F%2Fclients.neuralab.net%2Fclient-area%2F";
  5.   $url='https://'.$subdomain.'.harvestapp.com/oauth2/authorize?client_id='.$client_id.'&redirect_uri='.$redirect_uri.'&state=optional-csrf-token&response_type=code';
  6.   if(!isset($_GET['code'])){
  7.         wp_redirect($url);
  8.         exit;
  9.     }
  10.     else{
  11.         $code=$_GET['code'];
  12.         $pp=array(
  13.             'code'          => $code,
  14.             'client_id'     => $client_id,
  15.             'client_secret' => $client_secret,
  16.             'redirect_uri'  => $redirect_uri,
  17.             'grant_type'    => 'authorization_code'
  18.         );
  19.         $ppp = json_encode($pp);
  20.         echo $ppp;
  21.         $post_data="code=".$code."&client_id=".$client_id."&client_secret=".$client_secret."&redirect_uri=".$redirect_uri."&grant_type=authorization_code";
  22.         $headers = array(
  23.         "Content-type:application/x-www-form-urlencoded",
  24.     );
  25. //  $post_data="grant_type=password&username=alenmestrov@gmail.com&password=399ae0c91";
  26.         $ch=curl_init();
  27.         curl_setopt($ch, CURLOPT_URL,"https://".$subdomain.".harvestapp.com/oauth2/token");
  28.         curl_setopt($ch, CURLOPT_POST, 1);
  29.         curl_setopt($ch, CURLOPT_POSTFIELDS, $ppp);
  30.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  31.         $server_output = curl_exec($ch);
  32.         curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement