Created
May 2, 2013 13:57
-
-
Save lornajane/5502364 to your computer and use it in GitHub Desktop.
update the gist we made via the GitHub API, using PHP and streams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include "github-creds.php"; // sets $access_token | |
ini_set('user_agent', "PHP"); // github requires this | |
$api = 'https://api.github.com'; | |
$url = $api . '/gists/5501496'; // URL of the specific gist | |
// prepare the body data | |
$data = json_encode(array( | |
'description' => 'Rather Lame Poetry' | |
)); | |
// set up the request context | |
$options = ["http" => [ | |
"method" => "PATCH", | |
"header" => ["Authorization: token " . $access_token, | |
"Content-Type: application/json"], | |
"content" => $data | |
]]; | |
$context = stream_context_create($options); | |
// make the request | |
$response = file_get_contents($url, false, $context); | |
echo $response; | |
print_r(json_decode($response)); | |
print_r($http_response_header); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment