<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:Courier New,courier,monaco,monospace,sans-serif;font-size:12pt"><div><br></div><div style="font-family: Courier New,courier,monaco,monospace,sans-serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> J. Shirley &lt;jshirley@gmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> The elegant MVC web framework &lt;catalyst@lists.scsys.co.uk&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Thu, October 15, 2009 9:44:13 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Catalyst] Facebook canvas application in Catalyst<br></font><br>
<div class="gmail_quote">On Thu, Oct 15, 2009 at 12:25 PM, Gunnar Strand <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:gunnarstrand@yahoo.com" target="_blank" href="mailto:gunnarstrand@yahoo.com">gunnarstrand@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I am trying to write a Facebook canvas application in Catalyst using the WWW::Facebook::API plugin and I am tearing my hair trying to get it to work.<br>
<br>
I have no problems with access to my canvas application from Facebook, but I am unable to use any of the $c-&gt;facebook interface methods to acquire user data, eg. friend list, event information etc.<br>
<br>
I would be very grateful if anyone could post an example of, for instance, getting the currently logged in user's friends, or event information or any information at all via the $c-&gt;facebook interface. All I get is error when using the methods in the interface and the problem is definitely on this side of the keyboard.<br>

<br>
KR,<br>
Gunnar<br>
</blockquote><div><br><br>Hi Gunnar,<br><br>I've been meaning to write a blog entry on this, since there are some points to be aware of.&nbsp; I've built my own model that creates a per-context instance and works quite well.&nbsp; It isn't on CPAN (yet) but I should probably release it.<br>
<br>I would advise against using the Plugin, as it's not modifying the application behavior or dispatching so having it as a plugin is a bad fit.<br><br><span>I posted my code in a gist: <a target="_blank" href="http://gist.github.com/211218">http://gist.github.com/211218</a> </span><br>
</div></div><br>Keep in mind that you can't do differentiation on request type like GET/POST through the canvas.&nbsp; Make sure that you have the application added to your profile (check the app added, there is a chain mid-point to do this in the gist).<br>
<br>Hope this helps,<br><br>-J<br><br>Hi J,<br><br>Thank you for the quick reply! I have looked through the code and I cannot understand what the problem is for me. I have tried making this as simple as possible to eliminate any potential errors and still don't get it to work. I removed the plugin and I now have this code in the top index, some shamelessly copied from your page :-):<br><br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">sub index : Path : Args(0) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my ( $self, $c ) = @_;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my $client = new
 WWW::Facebook::API(</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; app_id&nbsp; =&gt; '174563349128',</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; api_key =&gt; 'ce82845d86baa6d633efa5f00d83575a',</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; desktop =&gt; 0,</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; secret&nbsp; =&gt; '&lt;secret id&gt;',</span><br style="font-family:
 Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; );</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my $params&nbsp;&nbsp;&nbsp; = $c-&gt;req-&gt;params;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my $fb_params = $client-&gt;canvas-&gt;get_fb_params( $c-&gt;req );</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; if (
 $params-&gt;{'auth_token'} ) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $client-&gt;auth-&gt;get_session( $params-&gt;{'auth_token'} );</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; }</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; if ( $fb_params-&gt;{session_key} ) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 $client-&gt;session_key( $fb_params-&gt;{session_key} );</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; }</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; </span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; use Data::Dumper;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my $output = Dumper( $client-&gt;friends-&gt;get );</span><br style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; $c-&gt;response-&gt;body( '&lt;pre&gt;' </span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; . $output </span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; . '&lt;/pre&gt;'</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; );</span><br style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;"><br>And the output is still:<br><br><pre>$VAR1 = {<br>          'error_msg' =&gt; 'Incorrect signature',<br>          'request_args' =&gt; [<br>                              {<br>                                'value' =&gt; 'ce82845d86baa6d633efa5f00d83575a',<br>                                'key' =&gt; 'api_key'<br>                              },<br>                              {<br>                                'value' =&gt; 'JSON',<br>                                'key' =&gt; 'format'<br>                              },<br>                              {<br>                                'value' =&gt; 'facebook.friends.get',<br>                                'key' =&gt; 'method'<br>                              },<br>                              {<br>                                'value' =&gt; '2.0POf_Dzs6W1VEJY2ZW1J5A__.86400.1255726800-100000257794276',<br>                                'key'
 =&gt; 'session_key'<br>                              },<br>                              {<br>                                'value' =&gt; '1.0',<br>                                'key' =&gt; 'v'<br>                              },<br>                              {<br>                                'value' =&gt; 'f5558065b76063dd63a8777eb5da8d7a',<br>                                'key' =&gt; 'sig'<br>                              }<br>                            ],<br>          'error_code' =&gt; 104<br>        };</pre><br><br>I've rechecked the api_key and secret, and they are correct. I guess that that the source above really should product useful output?<br><br>KR,<br>Gunnar<br>

</div></div></div></body></html>