I just wrote a little PHP script to put on a websites to generate a profile from a supplied Bitbucket username.
It pulls out the accounts Avatar, First Name, Last Name and public repositories and puts them in a nice little display. Its hardly anything fancy but its a nice little drop in for a website that can save you a little bit of time.
Any feedback, suggestions for improvement, or "hey you totally botched this, you should of done it this way" is greatly appreciated.
The Function
Code: Select all
function generateBitBucketProfile($title, $accountName, $email)
{
$jSonData = json_decode(file_get_contents("https://api.bitbucket.org/1.0/users/" . $accountName));
?>
<div class="bitbucketProfile">
<div class="title"><?=$title;?></div>
<img class="bitbucketAvatar" src="https://bitbucket.org/account/<?=$accountName;?>/avatar/64/" />
<div>Created By: <?=$jSonData->user->first_name;?> <?=$jSonData->user->last_name;?></div>
<div>Email: <?=$email;?></div>
<div>Bitbucket: <a href="http://bitbucket.org/<?=$accountName;?>/" target="_blank">http://bitbucket.org/<?=$accountName;?>/</a></div>
<div class="title">Repositories</div>
<?php
foreach ($jSonData->repositories as $repo)
{
?>
<div class="repo">
<a href="http://bitbucket.org/<?=$accountName;?>/<?=$repo->slug;?>/" target="_blank"><?=$repo->name;?></a><br />
<?=$repo->description?>
</div>
<?php
}
}
The repository has the script embedded in an actually web page with the needed styles to make it look nice. Since i wanted the entire thing to be contained in a single file the css is included in the head of the page instead of a separate file.
Demo of the script in action: http://phpaccountframework.voxelstudio3 ... rofile.php
Appreciate any feedback.