#1 Re: Developer Help » Using the Facebook API » June 11, 2016 10:17am

I have got to the bottom of it now, you are right it does work.
It the absence of documentation, I had erroneously assumed that it worked like the last Facebook integration I did. It used an App Token which didn't need a return url as it didn't use OAuth. I couldn't understand why yours needed it, so I re-wrote the class to use App Token instead. While this is fine you only get App privileges and not the privileges of the person who logs in (User App Token). In my case that didn't matter but I can see why it would for other people. It didn't help that I couldn't find where to specify the ReturnUrl on the Facebook apps page, had to Google it in the end!

Just in response to your last comment, does that mean that all PHP classes will be in a separate file where the file is the class name because I was going to mention that as a 'developers' feature request. It would really make jumping around Eclipse a lot easier!

#2 Re: Developer Help » Using the Facebook API » June 7, 2016 9:21pm

Haha, barebones - you're not kidding! But there was enough infrastructure to get me going. My Facebook AppId/Secret are fine and so I've spent most of the day looking at the code and concluded that it can't work!

Calling "new BigTreeFacebookAPI(false)" does not get an access token. It loads one from bigtree_settings and refreshes it (if needed). However, if the bigtree_settings doesn't contain an access_token (which it didn't on the first run) then the condition "if ($this->Settings["key"] && $this->Settings["secret"] && $this->Settings["token"]) {" in BigTreeOAuthAPIBase::__constructor() is never true and so Connected is never set to true. From that point everything returns "This API is not connected".

Basically if you have an access_token, even an expired one, you're ok; but if you don't have one there doesn't seem to be anyway of getting one!

I've added a check to BigTreeOAuthAPIBase's constructor which checks to see if Settings["token"] is set. If it isn't then it calls the OAuth API to get one, which is then saved to the bigtree_settings table and the world is wonderful again!

Now that it is working I've created BigTreeFacebookAlbum and BigTreeFacebookPicture. Just got a few bits and pieces to do but expect another branch push soon.

Probably need to add this to the bug tracking system at some point too. Hope I'm not messing up your roadmap!!

#3 Developer Help » Using the Facebook API » June 7, 2016 12:17pm

davidnewcomb
Replies: 5

I have been trying to get the BigTreeFacebookAPI working. I have filled in the appId and secret but I don't know what to write in order to call getPicture().

I am adding the code to my view file at bigtree2/templates/routed/news/detail.php

<?php
$c = new BigTreeFacebookAPI;
$u = $c->getUser();
$url = $u->getPicture();
?>

But all I get is an exception saying:
Fatal error: Uncaught exception 'Exception' with message 'This API is not connected.' in /Applications/XAMPP/xamppfiles/htdocs/my-app/bigtree2/core/inc/bigtree/apis/_oauth.base.php on line 252
Exception: This API is not connected. in /Applications/XAMPP/xamppfiles/htdocs/my-app/bigtree2/core/inc/bigtree/apis/_oauth.base.php on line 252
Call Stack

The documentation on this subject is a bit bare so can anyone help?

#4 Re: Feature Requests » New field type "Raw" » March 24, 2016 5:52pm

It was pretty simple to convert it each time but I think that in order to conform to DRY principles the repeated code should be held in the type rather than in everyone's code. It doesn't really matter if it's one line of code or a hundred lines: principles are principles wink

#5 Feature Requests » New field type "Raw" » March 21, 2016 9:56pm

davidnewcomb
Replies: 3

I've created a routed template in order to build a "contact us" page. I have created a resource of type "Text Area" called "email_addresses" with the subtitle "Email recipients, one per line e.g. David Newcomb <david.newcomb@example.com>".
I have built a form and I want to loop through this list sending emails to each recipient. Unfortunately when I retrieve the text area contents all the < and > have been converted to &lt; and &gt;.
It looks like I'll have to do some html_entity_decode'ing but it occurred to me that a Raw field type would be more useful as it could be used to store other things that don't want to be mangled.

#6 General » Linking to another page » March 20, 2016 9:41pm

davidnewcomb
Replies: 1

Is it possible to link to another page from inside an HTML block? I can add links but this only lets you link to files you have uploaded. Is there a way of creating a link to another page on the site. I don't really want to put static links in because it makes things tricky when the site moves between different environments.

#7 Re: General » User Login / Register » March 17, 2016 10:23pm

I have created a work around that gives me users and protected areas. (Apache only)
1) Make sure your installation uses "End URLs with /".
2) Create a folder in your document root with the same name as the (virtual) folder you want to protect.
3) Create an .htaccess file with:

AuthType Basic
AuthName "Members Area"
AuthUserFile "/path/to/.htpasswd"
require valid-user

4) Add users to the file using htpasswd.

The solution is a bit system-administrator'y but it gets you up and running with no code changes or module/extension installations.

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.