Get GitHub tags into PHP Array -


basically need tags given repo , place result in php array

i've seen github api; returning array of tags have no experience curl.

i think url https://api.github.com/repos/joshf/myrepo/git/refs/tag i'm not sure how answer array

i found guide v2 of github api not v3

any appreciated

edit:

<?php   $url = "https://api.github.com/repos/joshf/burden/git/refs/tags"; $ch=curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_useragent, "test"); $r=curl_exec($ch); curl_close($ch);  echo $r;  $response_array = json_decode($r, true); echo $response_array->{"ref"};  ?> 

gives me

[{"ref":"refs/tags/1.2","url":"https://api.github.com/repos/joshf/burden/git/refs/tags/1.2","object":{"sha":"d04eabe44b52e65ca2e1c1eaaca4321195d85001","type":"tag","url":"https://api.github.com/repos/joshf/burden/git/tags/d04eabe44b52e65ca2e1c1eaaca4321195d85001"}},{"ref":"refs/tags/1.3","url":"https://api.github.com/repos/joshf/burden/git/refs/tags/1.3","object":{"sha":"74d40e3f89717cbadc11e23e8ab4350d85deb015","type":"tag","url":"https://api.github.com/repos/joshf/burden/git/tags/74d40e3f89717cbadc11e23e8ab4350d85deb015"}}] 

all want 1.2 , 1.3 bit of tags

you can decode response associated array json_decode function, passing association true

 $resonse_array = json_decode($content, true); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -