tag:blogger.com,1999:blog-5392343262163971792024-03-13T19:38:50.642-07:00voidfractionAnonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-539234326216397179.post-12658146529608502962012-11-14T09:51:00.000-08:002012-11-14T10:01:12.674-08:00Laser cut paper structures with generated supportsI've been working on various iterations of this program since my junior year of college. It's gone through some significant changes in that time.<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h3 class="separator" style="clear: both; text-align: left;">
Acrylic Triangles and edges. Horrible toxic solvent glue.</h3>
<div style="text-align: left;">
<a href="http://farm6.staticflickr.com/5025/5597398205_78915c5b0b.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://farm6.staticflickr.com/5025/5597398205_78915c5b0b.jpg" width="400" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<h3>
Acrylic Triangles and paired edges attached using cotter pins. Heavy wire support structure threaded through holes in connectors. </h3>
</div>
<div style="text-align: left;">
<a href="http://farm6.staticflickr.com/5102/5683792400_31cf9aed25.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://farm6.staticflickr.com/5102/5683792400_31cf9aed25.jpg" width="400" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<h3>
Coroplast Triangles and Acrylic snap-on edges. </h3>
</div>
<ol style="text-align: left;"><ol>
</ol>
</ol>
<div style="text-align: left;">
<a href="http://farm7.staticflickr.com/6056/6252225646_c596db7751.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://farm7.staticflickr.com/6056/6252225646_c596db7751.jpg" width="300" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<h3>
And Now: Triangular card stock tiles with generated support structure</h3>
<h3>
</h3>
</div>
<div style="text-align: left;">
<h4>
Process:</h4>
<h4>
</h4>
</div>
<div style="text-align: left;">
.OBJ files. Left is visualization of final geometry. Right is source </div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-dY50jSuREFo/UKPC0XhG97I/AAAAAAAACbA/YPycUe_aKXg/s1600/lcalg+before+and+afte.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="312" src="http://1.bp.blogspot.com/-dY50jSuREFo/UKPC0XhG97I/AAAAAAAACbA/YPycUe_aKXg/s640/lcalg+before+and+afte.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Generated .DXF (vector graphics format) file for laser cutting. </div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-HSXfKz3nVB4/UKPHHYnprgI/AAAAAAAACbQ/16HN84n8-y8/s1600/lcalg+acad+screenshot.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="344" src="http://1.bp.blogspot.com/-HSXfKz3nVB4/UKPHHYnprgI/AAAAAAAACbQ/16HN84n8-y8/s640/lcalg+acad+screenshot.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Red lines are cut, Blue lines are perforated for folding and white text is raster fill.</td></tr>
</tbody></table>
<div style="text-align: left;">
<h4>
Result:</h4>
<h4>
</h4>
</div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-gM6pQSc9fQc/UKPMH4pEHCI/AAAAAAAACbg/8y1DuQZNL9M/s1600/IMG_20121113_213039.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="http://3.bp.blogspot.com/-gM6pQSc9fQc/UKPMH4pEHCI/AAAAAAAACbg/8y1DuQZNL9M/s400/IMG_20121113_213039.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Folded tiles during assembly</td></tr>
</tbody></table>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-ICdZMDJ_Yco/UKPMPaPotCI/AAAAAAAACbo/-E1I4fltxRA/s1600/IMG_20121113_215739.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="http://1.bp.blogspot.com/-ICdZMDJ_Yco/UKPMPaPotCI/AAAAAAAACbo/-E1I4fltxRA/s400/IMG_20121113_215739.jpg" width="300" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Assembled object, supporting a subset of my library</td></tr>
</tbody></table>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com1tag:blogger.com,1999:blog-539234326216397179.post-5815679448032779732011-12-08T12:34:00.000-08:002011-12-08T12:34:01.764-08:00Facebook Graph API cookbook page<div style="background-color: transparent;"><span id="internal-source-marker_0.264045518822968" style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Working with the Graph API</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Overview</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The graph API is a collection of RESTful web services facebook provides. Using the graph api, you can publish, interact with or create almost anything in facebook. Developers make GET, POST and DELETE requests to different parts of https://graph.facebook.com. These requests can require an access token, which grants read/write privileges. </span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Facebook provides a tool at </span><a href="https://developers.facebook.com/tools/explorer"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">https://developers.facebook.com/tools/explorer</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> that lets users generate access tokens for their account with any combination of permissions and make graph api calls. Try using this tool to interact with your facebook accounts. You can read facebook’s graph api documentation here: </span><a href="https://developers.facebook.com/docs/reference/api/"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">https://developers.facebook.com/docs/reference/api/</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Body</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">GETing </span><a href="https://graph.facebook.com/1206427506"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">https://graph.facebook.com/1206427506</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> (my facebook user id) with no access token returns this JSON:</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">{</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "id": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://graph.facebook.com/1206427506"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1206427506</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Paul Kinsky"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "first_name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Paul"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "last_name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Kinsky"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "link": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://www.facebook.com/people/Paul-Kinsky/1206427506"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">https://www.facebook.com/people/Paul-Kinsky/1206427506</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "gender": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"male"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "locale": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"en_US"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "type": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"user"</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">}</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The same call with an access token granting the user_about_me privilege to my account returns this JSON:</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">{</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "id": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://graph.facebook.com/1206427506"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1206427506</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Paul Kinsky"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "first_name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Paul"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "last_name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Kinsky"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "link": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://www.facebook.com/profile.php?id=1206427506"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">https://www.facebook.com/profile.php?id=1206427506</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "hometown": {</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "id": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://graph.facebook.com/113001432047882"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">113001432047882</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Wareham, Massachusetts"</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> },</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "location": {</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "id": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://graph.facebook.com/105596609473837"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">105596609473837</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Worcester, Massachusetts"</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> },</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "gender": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"male"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "timezone": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">-5</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "locale": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"en_US"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "languages": [</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> {</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "id": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><a href="https://graph.facebook.com/113301478683221"><span style="background-color: #f2f2f2; color: #3b5998; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">113301478683221</span></a><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "name": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"American English"</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> }</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> ],</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "verified": </span><span style="background-color: #f2f2f2; color: blue; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">true</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "updated_time": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"2011-11-02T16:50:18+0000"</span><span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">,</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> "type": </span><span style="background-color: #f2f2f2; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"user"</span><br />
<span style="background-color: #f2f2f2; color: #333333; font-family: Verdana; font-size: 11px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">}</span><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The facebook php sdk handles graph api calls with the Facebook::api() method. </span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;"><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$facebook->api('/me/feed', 'POST',<br class="kix-line-break" /> array(<br class="kix-line-break" /> 'link' => 'www.example.com',<br class="kix-line-break" /> 'message' => 'Posting with the PHP SDK!'<br class="kix-line-break" /> ));</span></div><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Graph API reference:</span><br />
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;"><a href="https://developers.facebook.com/docs/reference/api/user/#posts"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">https://developers.facebook.com/docs/reference/api/user/#posts</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span></div><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Components:</span><ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$facebook</span></li>
<ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">a Facebook object initialized with your application’s APP_ID and APP_SECRET</span></li>
</ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">'/me/feed'</span></li>
<ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">the part of the facebook graph api to contact</span></li>
<li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">in this case, the feed of the current user</span></li>
</ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">‘POST’</span></li>
<ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">the type of request</span></li>
<li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">in this case, we’re POSTing to the current user’s feed</span></li>
</ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">array(...)</span></li>
<ol><li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">parameters specific to the graph api call</span></li>
<li style="background-color: transparent; font-family: Arial; font-size: 15px; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">in this case, we’re posting a link to 'www.example.com' and the message that we’re 'Posting with the PHP SDK!' to the currently logged in user’s feed, or news feed.</span></li>
</ol></ol><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Here’s an example using this code from facebook’s documentation:</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Example code</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><?<br class="kix-line-break" /> // Remember to copy files from the SDK's src/ directory to a<br class="kix-line-break" /> // directory in your application on the server, such as php-sdk/<br class="kix-line-break" /> require_once('php-sdk/facebook.php');</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">//These parameters can be viewed when you create your test app here: //</span><a href="https://developers.facebook.com/apps"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">https://developers.facebook.com/apps</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /> $config = array(<br class="kix-line-break" /> 'appId' => 'YOUR_APP_ID',<br class="kix-line-break" /> 'secret' => 'YOUR_APP_SECRET',<br class="kix-line-break" /> );<br class="kix-line-break" /><br class="kix-line-break" /> $facebook = new Facebook($config);<br class="kix-line-break" /> $user_id = $facebook->getUser();<br class="kix-line-break" />?><br class="kix-line-break" /><html><br class="kix-line-break" /> <head></head><br class="kix-line-break" /> <body><br class="kix-line-break" /><br class="kix-line-break" /> <?<br class="kix-line-break" /> if($user_id) {<br class="kix-line-break" /><br class="kix-line-break" /> // We have a user ID, so probably a logged in user.<br class="kix-line-break" /> // If not, we'll get an exception, which we handle below.<br class="kix-line-break" /> try {<br class="kix-line-break" /> $ret_obj = $facebook->api('/me/feed', 'POST',<br class="kix-line-break" /> array(<br class="kix-line-break" /> 'link' => 'www.example.com',<br class="kix-line-break" /> 'message' => 'Posting with the PHP SDK!'<br class="kix-line-break" /> ));<br class="kix-line-break" /> echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';<br class="kix-line-break" /><br class="kix-line-break" /> } catch(FacebookApiException $e) {<br class="kix-line-break" /> // If the user is logged out, you can have a <br class="kix-line-break" /> // user ID even though the access token is invalid.<br class="kix-line-break" /> // In this case, we'll get an exception, so we'll<br class="kix-line-break" /> // just ask the user to login again here.<br class="kix-line-break" /> $login_url = $facebook->getLoginUrl( array(<br class="kix-line-break" /> 'scope' => 'publish_stream'<br class="kix-line-break" /> )); <br class="kix-line-break" /> echo 'Please <a href="' . $login_url . '">login.</a>';<br class="kix-line-break" /> error_log($e->getType());<br class="kix-line-break" /> error_log($e->getMessage());<br class="kix-line-break" /> } <br class="kix-line-break" /> // Give the user a logout link <br class="kix-line-break" /> echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';<br class="kix-line-break" /> } else {<br class="kix-line-break" /><br class="kix-line-break" /> // No user, so print a link for the user to login<br class="kix-line-break" /> // To post to a user's wall, we need publish_stream permission<br class="kix-line-break" /> // We'll use the current URL as the redirect_uri, so we don't<br class="kix-line-break" /> // need to specify it here.<br class="kix-line-break" /> $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );<br class="kix-line-break" /> echo 'Please <a href="' . $login_url . '">login.</a>';<br class="kix-line-break" /><br class="kix-line-break" /> } <br class="kix-line-break" /><br class="kix-line-break" /> ?> <br class="kix-line-break" /><br class="kix-line-break" /> </body> <br class="kix-line-break" /></html> </span></div>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-885352819612107412011-12-08T11:17:00.001-08:002011-12-08T11:17:02.343-08:00Facebook Auth cookbook page<div style="background-color: transparent;"><span id="internal-source-marker_0.813427105313167" style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Facebook Authentication</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Overview</span><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Most actions on Facebook require some sort of authentication token. For example, sending a request for information about a user without the relevant auth token returns only their public information: name, user id, and a few other fields. However, a request with the proper token can GET several pages of JSON describing a user who’s authorized the requesting app.</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Body</span><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">There are several ways to acquire such a token, but we will be focusing on a simple method using the PHP SDK. Complete documentation can be found </span><a href="https://developers.facebook.com/docs/authentication/"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">here</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">First, working with the PHP SDK requires initializing an instance of the Facebook object with your App_ID and App_Secret. These values are unique to each app, and can be thought of as you username and password.</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Facebook::getLoginUrl(params) method generates a url that takes the user to a facebook dialouge where the user is asked if they would like to grant your application the permissions specified in params, after which the user is redirected to either a url specified in params or the originating page</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">From the </span><a href="https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">documentation</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">:</span><br />
<div dir="ltr" style="margin-bottom: 0pt; margin-left: 36pt; margin-top: 0pt;"><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$params = array(<br class="kix-line-break" /> <span class="Apple-tab-span" style="white-space: pre;"> </span>scope => 'read_stream, friends_likes',<br class="kix-line-break" /> <span class="Apple-tab-span" style="white-space: pre;"> </span>redirect_uri => 'https://www.myapp.com/post_login_page'<br class="kix-line-break" />);<br class="kix-line-break" /><br class="kix-line-break" />$loginUrl = $facebook->getLoginUrl($params);</span></div><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">the scope parameter can be any of these </span><a href="https://developers.facebook.com/docs/reference/api/permissions/"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">permissions</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">. Remember that requesting unnecessary permissions will make users suspicious.</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The auth token obtained is temporary, meaning that this method can only be used when the user is online or shortly after. </span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">There is also a Facebook::getLogoutUrl() method, see the example below for a full example (</span><a href="https://developers.facebook.com/docs/reference/php/facebook-api/"><span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;">source</span></a><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">)</span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Example Code</span><span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<span style="background-color: transparent; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<div dir="ltr" style="margin-bottom: 0pt; margin-left: 14pt; margin-right: 14pt; margin-top: 0pt;"><span style="background-color: white; font-family: Arial; font-size: 15px; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><?<br class="kix-line-break" /> // Remember to copy files from the SDK's src/ directory to a<br class="kix-line-break" /> // directory in your application on the server, such as php-sdk/<br class="kix-line-break" /> require_once('php-sdk/facebook.php');<br class="kix-line-break" /><br class="kix-line-break" /> $config = array(<br class="kix-line-break" /> 'appId' => 'YOUR_APP_ID',<br class="kix-line-break" /> 'secret' => 'YOUR_APP_SECRET',<br class="kix-line-break" /> );<br class="kix-line-break" /><br class="kix-line-break" /> $facebook = new Facebook($config);<br class="kix-line-break" /> $user_id = $facebook->getUser();<br class="kix-line-break" />?><br class="kix-line-break" /><html><br class="kix-line-break" /> <head></head><br class="kix-line-break" /> <body><br class="kix-line-break" /><br class="kix-line-break" /> <?<br class="kix-line-break" /> if($user_id) {<br class="kix-line-break" /><br class="kix-line-break" /> // We have a user ID, so probably a logged in user.<br class="kix-line-break" /> // If not, we'll get an exception, which we handle below.<br class="kix-line-break" /> try {<br class="kix-line-break" /><br class="kix-line-break" /> $user_profile = $facebook->api('/me','GET');<br class="kix-line-break" /> echo "Name: " . $user_profile['name'];<br class="kix-line-break" /><br class="kix-line-break" /> } catch(FacebookApiException $e) {<br class="kix-line-break" /> // If the user is logged out, you can have a <br class="kix-line-break" /> // user ID even though the access token is invalid.<br class="kix-line-break" /> // In this case, we'll get an exception, so we'll<br class="kix-line-break" /> // just ask the user to login again here.<br class="kix-line-break" /> $login_url = $facebook->getLoginUrl(); <br class="kix-line-break" /> echo 'Please <a href="' . $login_url . '">login.</a>';<br class="kix-line-break" /> error_log($e->getType());<br class="kix-line-break" /> error_log($e->getMessage());<br class="kix-line-break" /> } <br class="kix-line-break" /> } else {<br class="kix-line-break" /><br class="kix-line-break" /> // No user, print a link for the user to login<br class="kix-line-break" /> $login_url = $facebook->getLoginUrl();<br class="kix-line-break" /> echo 'Please <a href="' . $login_url . '">login.</a>';<br class="kix-line-break" /><br class="kix-line-break" /> }<br class="kix-line-break" /><br class="kix-line-break" /> ?><br class="kix-line-break" /><br class="kix-line-break" /> </body><br class="kix-line-break" /></html></span></div></div>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-25811488285473771292011-11-03T14:47:00.000-07:002011-11-06T10:43:14.937-08:00Associating facebook and ASM accountsHere's how it's done:<br />
<br />
<a href="http://developers.facebook.com/docs/plugins/registration/">http://developers.facebook.com/docs/plugins/registration/</a><br />
This pops up an iframe that has in it a form prefilled with your facebook data. It also supports custom fields. You can fill out or change any fields you want to and then submit the form as a signed request to the server.<br />
<br />
If a user only has a Facebook account, they can just register with this to create an associated ASM account.<br />
<br />
When an ASM account is already logged in, we should be able to use the same form with different parameters to associate the two accounts.<br />
<br />
Edit: Code is here: http://pkinsky.com/register.htmlAnonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-70184752623481821072011-11-03T13:24:00.000-07:002011-11-03T13:24:06.992-07:00Share pages with friends Like shares with all, send allows you to choose recipients from among your friends. <br />
<br />
http://www.pkinsky.com/askhelp.htmlAnonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-84758477828338605912011-10-30T16:22:00.000-07:002011-10-31T07:41:31.561-07:00API progressAs of now, I've made a test api call that gets a database object, saves data to it, and then reads other data from it. I've also managed to create 'watcher' database objects via API and retrieve data from them (a callback url) elsewhere.<br />
<br />
The next step is to send a POST request to that callback_url when the relevant event happens. This can be expanded to cover assignments being added, achievements, etc.<br />
<br />
EDIT: and then I uploaded the code - my api call is test_call in lib/gwt/ajax.rb<br />
<br />
EDIT2: now featuring working post/response of JSON data to and from an external php script! Proof of concept finished, time to start on the actual product.Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-83234613900825956972011-10-26T16:52:00.000-07:002011-10-26T16:52:15.827-07:00Assistments API finally workingI just got my hello world assistments api call working. Awesome.Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-35488357761410535662011-10-23T16:42:00.000-07:002011-10-23T16:48:16.453-07:00Source Code and Documentation<div style="background-color: black; color: white;"><span id="internal-source-marker_0.49535691978396246" style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">First, I want to say that I’ve open-sourced LcAlg, my program for generating laser-cut polygonal sculptures from 3d models. There’s a link a little bit farther down on the page if that’s what you came here for.</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Second, the majority of this post will be about an interesting method of connecting coroplast sheets using acrylic connectors that I’ve developed.</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;">Source Code</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; vertical-align: baseline;">svn co https://lcalg.svn.sourceforge.net/svnroot/lcalg lcalg </span><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline;">https://sourceforge.net/projects/lcalg/files/</span><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><ol style="background-color: black; color: white;"><li style="font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Check out the code. Download either of the two obj files and put them in the input folder. </span></li>
</ol><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><ol start="2" style="background-color: black; color: white;"><li style="font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Adjust constants in util.constants.py to change most values in the program. Currently it’s set to use 2.5mm acrylic and ~3.5mm coroplast.</span></li>
</ol><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><ol start="3" style="background-color: black; color: white;"><li style="font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Run LcAlg by running LcAlg.py. You’ll need python 2.7.</span></li>
</ol><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><ol start="4" style="background-color: black; color: white;"><li style="font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Watch for updates. This is an early beta that I’ll be updating regularly.</span></li>
</ol><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;">Connectors</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Coroplast is essentially plastic cardboard. It is lightweight and flexible, and bends rather than breaking. I now use it for the triangles, or faces, in my models.</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">I used to use acrylic plates for both the faces and the connectors. It was shatter-prone, heavy and expensive. I secured the faces to the connectors with first solvent glue and then cotter pins. This worked, but was labor intensive and in some cases fragile.</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">The solution is to use acrylic connectors and coroplast sheets. This leverages the strength of both materials. Because the coroplast is flexible, I use retaining tabs - the coroplast deforms around the rigid acrylic tabs and is locked into place</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">This forms a very strong connection. I have to pull very hard to force the pieces apart. However, I can easily remove a connector by slipping the retaining tabs over the coroplast retainer. Think zip ties - all it takes is a small piece of metal to jimmy one open but brute force will get you nowhere.</span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span><br />
<br />
<br />
<img height="395px;" src="https://lh6.googleusercontent.com/Ouk4qmCMtygV8SR1Uv3qma8bUWuWO2lV_ELrbyCd3fNLeD5bpkVRDcC9eb5ksfJEFMoBp5ggXaEoV91gVTBObZpCQ3lxTLIfO9giTBy4VVqNSSNX2yU" width="459px;" /></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;">(By vector-cut I mean vector-etched)<br />
<br />
<span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Unfortunately, sharp angles lead to an issue that can be seen in this diagram: if angle A increases much more, distance B will decrease until there is not enough material there to hold the connector together</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Large angle A’s can also lead to intersecting faces: In the diagram below, imagine if angle A were to increase. The two coroplast panels would quickly be intersecting. LcAlg solves this issue by calculating an offset and then removing that much material from the relevant edge.</span></div><div style="background-color: black; color: white;"><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline;">Faces</span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span><br />
<br />
<img height="293px;" src="https://lh3.googleusercontent.com/JYLWnlIZqVxIDKtqGTy20i3maNlWzJkcUab8QgRcIjQN5s6lzUes-n-3TfD_TLvSgIrloizLnVuMfcvYmCtbytZr2zagtB1Ia5UAP3UYS9FVygp-fr0" width="409px;" /></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><br />
<br />
<span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">A face is a flat coroplast triangle with 3 pairs of two mounting points for the acrylic connectors.</span><br />
<br />
</div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="background-color: black; color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">They’re cut out as below, to save laser time and material. </span></div>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com3tag:blogger.com,1999:blog-539234326216397179.post-34823119761153950842011-10-23T15:31:00.000-07:002011-10-23T15:31:51.028-07:00LcAlgI've made an algorithm that transforms a 3d model (a mesh of triangles) into the autoCAD files neccesary to laser-cut a set of triangles and angled connectors that, when assembled, form a real life version of that 3d model.<br />
<br />
You can see an example <a href="http://blog.makezine.com/archive/2011/10/polygonal-rhino-head.html">here</a><br />
<br />
This is an intro post. In later posts I'll go over how it works and how to use it.<br />
<br />
<br />
Source code can be found here: https://sourceforge.net/projects/lcalg/Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-45118150722014746092011-10-05T20:03:00.000-07:002011-10-05T20:03:14.619-07:00Assistments APIWe've decided that the best way to go forwards is to work with Assistments as a service. We'll be extending the existing API to do what we need, instead of trying to add new functionality directly to Assistments.<br />
<br />
<br />
Fortunately, Assistments already has at least the beginnings of an API.Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-27521761012520039592011-10-03T06:22:00.000-07:002011-10-03T06:22:52.408-07:00PHP and JS Guidlines for FB: Acronyms!I've put together a guide on the php and javascript sdks for facebook. It mostly consists of links to facebook's own documentation, which is amazing. This needs to be cleaned up, but these links show examples on pretty much every part of facebook's api.<br />
<br />
<br />
php: <br />
login/out and requesting permissions, posting to a user’s wall, getting a user’s information all with graph api, newest api <a class="external" href="http://developers.facebook.com/docs/reference/php/facebook-api/" target="wikiext">http://developers.facebook.com/docs/reference/php/facebook-api/</a> <br />
methods for login/logout <a class="external" href="http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/" target="wikiext">http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/</a> <a class="external" href="http://developers.facebook.com/docs/reference/php/facebook-getLogoutUrl/" target="wikiext">http://developers.facebook.com/docs/reference/php/facebook-getLogoutUrl/</a> <br />
what to show depends on result of <a class="external" href="http://developers.facebook.com/docs/reference/php/facebook-getUser/" target="wikiext">http://developers.facebook.com/docs/reference/php/facebook-getUser/</a> <br />
You should also authorize your app using the values from you facebook developer app page <a class="external" href="http://developers.facebook.com/docs/reference/php/facebook-setAppId/" target="wikiext">http://developers.facebook.com/docs/reference/php/facebook-setAppId/</a> <a class="external" href="http://developers.facebook.com/docs/reference/php/facebook-setAppSecret/" target="wikiext">http://developers.facebook.com/docs/reference/php/facebook-setAppSecret/</a> <br />
i dont see it in the docs explicitly but in the examples this method is used to init facebook object: <br />
$config = array( 'appId' => 'YOUR_APP_ID', 'secret' => 'YOUR_APP_SECRET', ); <br />
$facebook = new Facebook($config); <br />
javascript <br />
info, how to load sdk <a class="external" href="http://developers.facebook.com/docs/reference/javascript/" target="wikiext">http://developers.facebook.com/docs/reference/javascript/</a> <br />
FB.login() -- login and/or request extended permissions FB.logout() -- logout (only if the user is connected with your application) FB.getLoginStatus() -- get current login status from facebook.com FB.getSession() -- synchronous accessor for the current session. Note that in OAuth 2.0, this function will no longer function and you should use FB.getAuthResponse(). FB.getAuthResponse() -- accessor for the current authorization response record, which for connected users includes an access token, a signed request, and a user ID. <br />
api calls: <a class="external" href="http://developers.facebook.com/docs/reference/javascript/FB.api/" target="wikiext">http://developers.facebook.com/docs/reference/javascript/FB.api/</a> <br />
can trigger dialogs with ui methods <a class="external" href="http://developers.facebook.com/docs/reference/javascript/FB.ui/" target="wikiext">http://developers.facebook.com/docs/reference/javascript/FB.ui/</a> <br />
lots of useful methods - can control position, size, etc for canvas page, login/out, etc <br />
you can make calls in facebook query language to get info <a class="external" href="http://developers.facebook.com/docs/reference/fql/" target="wikiext">http://developers.facebook.com/docs/reference/fql/</a>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-46417683971505988492011-09-28T20:20:00.000-07:002011-09-28T20:20:10.647-07:00AppRequest functionality added to fb_graph gemThe developer of the fb_graph facebook graph api gem helped me out by adding the ability to post app-generated requests! Thanks, Nov Matake!<br />
<br />
(https://github.com/nov/fb_graph/wiki/App-Request)Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-25848066882583078392011-09-28T04:14:00.000-07:002011-09-28T04:15:07.206-07:00Everything I need to do in Ruby, but in PHPI've had 9/10ths of this working for about a week, I've just been stuck getting it into ruby. I'm just going to post some code for sending notifications, getting a user's notifications, and deleting them. It also handles login. <br />
<br />
<?php<br />
<br />
require 'facebook-php-sdk/src/facebook.php';<br />
<br />
// Create our Application instance (replace this with your appId and secret).<br />
$facebook = new Facebook(array(<br />
'appId' => '168953989848835',<br />
'secret' => '60359e93359d47a9d349c3dd263a479a',<br />
));<br />
<br />
// Get User ID<br />
$user = $facebook->getUser();<br />
<br />
// We may or may not have this data based on whether the user is logged in.<br />
//<br />
// If we have a $user id here, it means we know the user is logged into<br />
// Facebook, but we don't know if the access token is valid. An access<br />
// token is invalid if the user logged out of Facebook.<br />
<br />
if ($user) {<br />
try {<br />
// Proceed knowing you have a logged in user who's authenticated.<br />
$user_profile = $facebook->api('/me');<br />
} catch (FacebookApiException $e) {<br />
error_log($e);<br />
$user = null;<br />
}<br />
}<br />
<br />
// Login or logout url will be needed depending on current user state.<br />
if ($user) {<br />
$logoutUrl = $facebook->getLogoutUrl();<br />
} else {<br />
$loginUrl = $facebook->getLoginUrl();<br />
}<br />
<br />
<br />
?><br />
<!doctype html><br />
<html xmlns:fb="http://www.facebook.com/2008/fbml"><br />
<head><br />
<title>php-sdk</title><br />
<style><br />
body {<br />
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;<br />
}<br />
h1 a {<br />
text-decoration: none;<br />
color: #3b5998;<br />
}<br />
h1 a:hover {<br />
text-decoration: underline;<br />
}<br />
</style><br />
</head><br />
<body><br />
<h1>php-sdk</h1><br />
<br />
<?php if ($user): ?><br />
<a href="<?php echo $logoutUrl; ?>">Logout</a><br />
<?php else: ?><br />
<div><br />
Login using OAuth 2.0 handled by the PHP SDK:<br />
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a><br />
</div><br />
<?php endif ?><br />
<br />
<h3>PHP Session</h3><br />
<pre><?php print_r($_SESSION); ?></pre><br />
<br />
<?php <br />
<br />
$app_id = '168953989848835';<br />
$app_secret = '60359e93359d47a9d349c3dd263a479a';<br />
<br />
$token_url = "https://graph.facebook.com/oauth/access_token?" .<br />
"client_id=" . $app_id .<br />
"&client_secret=" . $app_secret .<br />
"&grant_type=client_credentials";<br />
<br />
$app_access_token = file_get_contents($token_url);<br />
<br />
$user_id = substr($user.id, 0, -2);<br />
<br />
$apprequest_url ="https://graph.facebook.com/" .<br />
$user_id .<br />
"/apprequests?message='INSERT_UT8_STRING_MSG'" . <br />
"&data='INSERT_STRING_DATA'&" . <br />
$app_access_token . "&method=post";<br />
<br />
$result = file_get_contents($apprequest_url);<br />
#echo $user_id;<br />
echo "App Request sent?";<br />
echo "request id = " . $result;<br />
<br />
#$pieces = explode("=", $app_access_token);<br />
#echo $pieces[1];<br />
//Get all app requests for user<br />
<br />
$request_url ="https://graph.facebook.com/" .<br />
$user_id . "/apprequests?" .<br />
$app_access_token;<br />
$requests = file_get_contents($request_url);<br />
<br />
//Print all outstanding app requests<br />
echo '<pre>';<br />
print_r($requests);<br />
echo '</pre>';<br />
<br />
//Process and delete app requests<br />
$data = json_decode($requests);<br />
foreach($data->data as $item) {<br />
$id = $item->id;<br />
$delete_url = "https://graph.facebook.com/" .<br />
$id . "?" . $app_access_token . "&method=delete";<br />
<br />
$result = file_get_contents($delete_url);<br />
echo("Requests deleted is " . $result. ", message = " . $item->message);<br />
} <br />
<br />
?>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com1tag:blogger.com,1999:blog-539234326216397179.post-69338973538641831052011-09-27T19:06:00.000-07:002011-09-27T19:06:35.917-07:00WelpI was talking with the author of the fbgraph gem about how to do something, at least I ended up getting him to add it to his TODO list:<br />
<br />
https://github.com/nov/fb_graph/issues/126<br />
<br />
Go go gadget unsupported language!Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-68238794382427568162011-09-27T12:34:00.001-07:002011-09-27T12:35:34.667-07:00Project Outline<div style="color: white;"><span id="internal-source-marker_0.39923615846844474" style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">In the past few years there has been an industry-wide trend towards Facebook integration. It can even be seen on WPI’s JobFinder website. Essentially, the goal is to let users of your website engage with it through facebook. Apps can deliver alerts and news stories to users. Facebook also provides access to many other core features via API. Some examples are sending requests, awarding achievements, and creating events. It also gives apps their own page on Facebook’s site, where they can fill a ‘canvas’ which covers most of the page with anything they want.</span></div><div style="color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">We plan to build a facebook application that will accomplish these functions:</span></div><ol style="color: white;"><ol><li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">handle authentication: </span></li>
<ol><li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-roman; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">Our application will allow users to associate their Facebook account with their Assistments account using the OAUTH 2.0 protocol. </span></li>
<li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-roman; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">It will also request any necessary permissions from the user.</span></li>
</ol><li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">manage notifications</span></li>
<ol><li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-roman; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">When an event, such as a problem set being assigned, occurs, the application will generate a notification of some type.</span></li>
<li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-roman; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">When a user arrives at our app via a notification, we can redirect the user to the relevant page.</span></li>
</ol><li style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">It will also provide the infrastructure necessary to integrate Assistments further with facebook. For example, awarding achievements to users will be as simple as a single post request.</span></li>
</ol></ol><div style="color: white;"><br />
</div><div style="color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"></span></div><div style="color: white;"><span style="background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">This will be beneficial to students using Assistments because many younger children use facebook. With our application, assistments will be immediately visible to students in a place they already go. We hope that if we increase the convenience of using assistments, students will be more likely to do their assignments.</span></div>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-86957367725686517682011-09-26T09:28:00.000-07:002011-09-26T09:28:10.929-07:00Issues with ROR and FBI've been having a lot of trouble getting rails to work with facebook. They only support PHP and javascript SDKs, so I'm going to try using a ruby gem I found that integrates javascript and rails. <br />
<br />
<a href="https://github.com/cowboyd/therubyracer">https://github.com/cowboyd/therubyracer</a>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-12125625172830565452011-09-18T12:26:00.000-07:002011-09-18T12:26:26.074-07:00Progress with Facebook APII've been tinkering with the facebook API. So far, I have working versions of: <br />
<ol><li>Users can login and logout through my page.</li>
<li>Send <a href="http://developers.facebook.com/docs/channels/#requests">requests</a> from my app to registered users. Once issued they can be:</li>
<ol><li>updated with new info ("DUE IN 2 HOURS!" or "3 out of 5 questions completed")</li>
<li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">read ("A good common practice for Apps on Facebook.com is to detect if a user has any requests pending when your application loads and then prompt the user to complete the actions associated with the requests before continuing.")</li>
<li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">deleted (clear request when associated problem set is completed)</li>
</ol><li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">Register <a href="https://developers.facebook.com/docs/achievements/">achievements</a> that can then be awarded to users. They can then be:</li>
<ol><li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">read</li>
<li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">deleted</li>
</ol><li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">Award users <a href="https://developers.facebook.com/docs/score/">scores</a> for the app. They can then be:</li>
<ol><li>read</li>
<li style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">deleted</li>
</ol></ol><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">This is all PHP implementations of html POST requests. It will be easy to transfer to ROR once we get our version of ASSISTments running</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">Also, Screenshots!</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">Achievements and scores. It also autogenerates notifications about how you have x of y achievements for an app, or the highest score.</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><a href="http://2.bp.blogspot.com/-DYy4yHQETfs/TnZARpNtovI/AAAAAAAAAAs/w8-T_o3WcVw/s1600/achievement+screenshot.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="193" rba="true" src="http://2.bp.blogspot.com/-DYy4yHQETfs/TnZARpNtovI/AAAAAAAAAAs/w8-T_o3WcVw/s200/achievement+screenshot.png" width="200" /></a></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"> </div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">Requests from an app to a user: These show up in a few different places, including the main page.</div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">(I left the default text in)</div><div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-JaJnFTc6G2M/TnZAeAEXI1I/AAAAAAAAAAw/hdR6OX5pYHA/s1600/request+screenshot.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" rba="true" src="http://4.bp.blogspot.com/-JaJnFTc6G2M/TnZAeAEXI1I/AAAAAAAAAAw/hdR6OX5pYHA/s200/request+screenshot.png" width="168" /></a></div>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-61632378481866940382011-09-13T14:57:00.000-07:002011-09-13T14:57:35.498-07:00Assisments Facebook App UsersThe potential users for our Facebook app fall into three groups:. Here's some examples of how each group could use our app.<br />
<ol><li>students:</li>
<ol><li>The student logs onto facebook and sees a private notification through one or more of Facebook's notification systems. Notification examples:</li>
<ol><li>New assignment</li>
<li>Assignment grade available</li>
</ol><li>The student logs onto Facebook and completes a problem set through the Assistments app</li>
</ol><li>teachers</li>
<ol><li>unknown</li>
</ol><li>parents</li>
<ol><li>get notifications about their students grades and assignments</li>
</ol></ol>We recently got the results from a survey given to the parents of children using Assistments. We haven't been able to go through all of them, but there is some interest in getting notifications through Facebook.<br />
<ol><ol><ol></ol></ol></ol><div><br />
</div><div><br />
</div><div><br />
</div>Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0tag:blogger.com,1999:blog-539234326216397179.post-14137998958197316332011-09-13T13:16:00.000-07:002011-09-13T13:16:48.076-07:00Assistments ISP First PostHi! My name is Paul Kinsky. I'm a Computer Science major at Worcester Polytechnic Institute, WPI.<br />
<br />
I'm working on a project for several professors at integrate a to extend a piece of educational software called Assistments with social media. Right now we're working on a facebook app that would allow students to complete problem sets within facebook.<br />
<br />
We've been granted access to the source code today, by the end of the week we hope to have a working prototype. I'll be posting details as we go.Anonymoushttp://www.blogger.com/profile/13144143241277271386noreply@blogger.com0