Guest User

Untitled

a guest
Jan 8th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. var u = "CENTRAL\myusername";
  2. var p = "myp@ssword";
  3. var payload = {
  4. username: u,
  5. password: p,
  6. client: 'referer',
  7. referer: 'https://mycompany.com/myapp',
  8. expiration: '60',
  9. format: 'json',
  10. };
  11. var tokenUrl = 'https://gis.mycompany.com/public/tokens/generateToken';
  12. $.ajax({
  13. url: tokenUrl,
  14. type: "POST",
  15. crossDomain: true,
  16. dataType: 'text',
  17. data: payload,
  18. success: function(data){
  19. token = data;
  20. console.log(token)
  21. }
  22. });
  23.  
  24. $GISuser = "CENTRAL\myusername";
  25. $GISpassword = "myp@ssword";
  26. $GISurl = "https://gis.mycompany.com/public/tokens/generateToken";
  27. $payload = array(
  28. "username" => $GISuser,
  29. "password" => $GISpassword,
  30. "client" => "referer",
  31. "referer" => 'https://mycompany.com/myapp',
  32. "expiration" => "60",
  33. "format" => "json"
  34. );
  35.  
  36. $curl = curl_init();
  37. curl_setopt($curl, CURLOPT_POST, 1);
  38. curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
  39. curl_setopt($curl, CURLOPT_URL, $GISurl);
  40. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  41.  
  42. $result = curl_exec($curl);
  43. curl_close($curl);
  44.  
  45. echo $result;
Add Comment
Please, Sign In to add comment