fork download
  1. <?php
  2.  
  3. include "github-creds.php"; // sets $access_token
  4. ini_set('user_agent', "PHP"); // github requires this
  5.  
  6. $api = 'http://bond:007@192.168.0.114:8080/cb/rest';
  7. $url = $api . '/user/bond'; // no user info because we're sending auth
  8.  
  9. // prepare the body data
  10. 'Name' => 'newname'
  11. ));
  12. // set up the request context
  13. $options = ["http" => [
  14. "method" => "POST",
  15. "header" => ["Authorization: token " . $access_token,
  16. "Content-Type: application/json"],
  17. "content" => $data
  18. ]];
  19. $context = stream_context_create($options);
  20.  
  21. // make the request
  22. $response = file_get_contents($url, false, $context);
Success #stdin #stdout #stderr 0.03s 26412KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  include(github-creds.php): failed to open stream: No such file or directory in /home/Tm3u6K/prog.php on line 3
PHP Warning:  include(): Failed opening 'github-creds.php' for inclusion (include_path='.:/usr/share/php') in /home/Tm3u6K/prog.php on line 3
PHP Notice:  Undefined variable: access_token in /home/Tm3u6K/prog.php on line 16
PHP Warning:  file_get_contents(http://...@192.168.0.114:8080/cb/rest/user/bond): failed to open stream: Network is unreachable in /home/Tm3u6K/prog.php on line 23