title: How to generate Unique Integer Only IDs like Facebook Twitter
body: <p>After searching SO and other sites, I've failed to come up with conclusive evidence to how Facebook, Twitter and Pinterest generate their ID's. The reason this is needed is to avoid url collisions. Moving to an entirely different ID will prevent this because there wont be quadrillions of records.</p>
  
  <ul>
  <li>Facebook.com/username/posts/<em>362095193814294</em></li>
  <li>Pinterest.com/pin/<em>62487513549577588</em></li>
  <li>Twitter.com/#!/username/status/<em>17994686627061761</em></li>
  </ul>
  
  <p>If you look at Pinterest as an example, the first few digits relate to the user id, and the last 6 or so digits represent the save id which possibly could be an auto increment.</p>
  
  <p>To create a similar ID, but not unique I was able to use: <code>base_convert(user_id.save_id, 16, 10)</code>. The problem here is that it's not unique, ex: <code>base_convert(15.211, 16, 10)</code> vs. <code>base_convert(152.11, 16, 10)</code>. These two are the same. Simply just merging two unique sets of numbers will still produce duplicate results. Throwing <code>uniqid()</code> into the mix will essentially fix the duplicates, but this doesn't seem like a great practice.</p>
  
  <p>Update: Twitter appears to use this: <a href="https://github.com/twitter/snowflake" rel="noreferrer">https://github.com/twitter/snowflake</a></p>
  
  <p><strong>Any suggestions on generating a unique ID like the above examples?</strong></p>