Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This solution do not provides authentication:</p> <pre><code>// download the repo zip file $repofile = file_get_contents("https://bitbucket.org/$username/$reponame/get/tip.zip"); file_put_contents('tip.zip', $repofile); unset($repofile); </code></pre> <p>But curl allows it. So a zip archive can be downloaded from a private repository in same way like in first script.</p> <pre><code>$node = ''; // a node from repo, like c366e96f16... $fp = fopen($path, 'w'); $ch = curl_init("https://bitbucket.org/$username/$reponame/get/$node.zip"); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); </code></pre> <p>I have tested it for my bitbucket account. It's work very well.</p> <p>If necessary to get last changeset node that we should use bitbucket api <a href="https://confluence.atlassian.com/display/BITBUCKET/changesets+Resource#changesetsResource-GETalistofchangesets" rel="nofollow">GET a list of changesets</a>:</p> <pre><code>$username = 'login'; $password = 'pass'; $owner = $username; // if user is owner $repo = 'repo name'; $response = ""; $callback = function($url, $chunk) use (&amp;$response){ $response .= $chunk; return strlen($chunk); }; $ch = curl_init("https://api.bitbucket.org/1.0/repositories/$owner/$repo/changesets?limit=1"); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0')); curl_setopt($ch, CURLOPT_WRITEFUNCTION, $callback); curl_exec($ch); curl_close($ch); $changesets = json_decode($response, true); $node = $changesets['changesets'][0]['node']; $raw_node = $changesets['changesets'][0]['raw_node']; print($node . PHP_EOL); print($raw_node . PHP_EOL); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload