I'm having problems getting ACL working with CakePHP. I've been working with the CakePHP Cookbook 2.0 example Simple Acl controlled Application, and have gone through the steps twice, but I've run into the same problem both times.
Everything appears to be setup correctly.
I'm able to create my groups, and users.
The aros table appears to have the same rows shown in the example on the web.
The acos and aros_acos tables appear to get populated with values that resemble the article.
And when I visit a page that's setup to be protected, I'm presented with the login page.
But when I login using the account I created, I see the following error:
Warning (512): DbAcl::check() -
Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 1
[username] => dc
[email] => myemail#somedomain.com
[group_id] => 1
[created] => 2011-10-27 14:58:59
[modified] => 2011-10-27 14:58:59
)
)
Aco: /Posts/add [CORE/Cake/Controller/Component/AclComponent.php, line 303]
That account is setup as an administrator, and the administrator group has been granted access to everything ... so if it works, I shouldn't have a problem ... but it seems like there's a lower-level problem that's getting in my way. I can post my DB tables as well if that'd be helpful, but figured I'd start here. Thanks for any insight you can provide.
The documentation was updated to address this issue. If you add this in the beforeFilter method in AppController it resolves the problem.
$this->Auth->authorize = array(
AuthComponent::ALL => array('actionPath' => 'controllers'),
'Actions',
);
Add $this->Auth->allow('initDB'); in beforeFilter()
Related
I want to get all facebook group post using FB Graph API.
I searched , googled, seen documentation for graph api, asked to so many persons, all are saying it is possible
Also i'm providing link from stackoverflow which i referred and tried
How to get all posts of a group via facebook graph api
But as you can see the post is very much old (from 2013)
When i tried to send request using CURL, at that time i'm not getting any error not any data
When i tried below code
$publish = $facebook-api('https://graph.facebook.com/v2.3/'.$group_id.'/feed/?access_token='.$params['access_token']);
at least i'm getting something in response
Array
(
[og_object] => Array
(
[id] => 859455820800214
[type] => website
[updated_time] => 2015-06-04T12:18:15+0000
[url] => https://graph.facebook.com/v2.3/659988617465253/feed/
)
[share] => Array
(
[comment_count] => 0
[share_count] => 0
)
[id] => https://graph.facebook.com/v2.3/659988617465253/feed/
)
So i just wanted to know that is it really possible at this moment?
And one good thing is that when i'm trying it from Graph API Explorer, i'm getting the data properly.
So where i'm wrong ?
Any little help would be greatly accepted
Why don't you just use the Facebook PHP SDK?
https://developers.facebook.com/docs/reference/php/4.0.0
You can get the group's feed via /{group_id}/feed, as described at
https://developers.facebook.com/docs/graph-api/reference/v2.3/group/feed#read
Make sure your Access Token is of the right type and contains the right permissions.
I found a whole bunch of related questions here, but since Twitter had made a lot of changes in its API, most of them are outdated (+ nothing actually solved my problem).
So My website is a semi social network (with posts, likes comments etc). The user has the option to post to twitter and facebook through my site. Everything is working just fine, posts are finding their way to both FB and TW.
I'm using Twitter oauth php library, posting is done like so:
$response = $connection->post("statuses/update", array('status' => "Tweet"));
but when if I want to verify user's credentials like so:
$response = $connection->get("account/verify_credentials.json");
I get:
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)
I don't think the problem is in the authentication process nor in the app settings, for I was able to post a tweet but got that same error, both using the same access token (and obviously the same app).
apparently you get this 34 error for a variety of cases, the documentations is so ambiguous about it.
So any troubleshooting techniques are appreciated.
Just use
$response = $connection->get("account/verify_credentials"); // Remove the .json
I need to work out if a user has my app installed so I can display a slighlty different page. How do you do this?
Ideally you'd want to capture their Facebook user ID in your own database when they originally install your app. When they come back, you can compare the current users Facebook user ID with your database to see if you find any matches.
If you don't have a database, you can always check on a user permissions using the Graph API. You can find the code here: http://developers.facebook.com/blog/post/495
This will give you back an array that looks something like this:
Array ( [data] => Array ( [0] => Array ( [installed] => 1 [bookmarked] => 1 ) ) )
In this case, the user has it installed and has bookmarked it. Now that you know that, you can display a slightly different page.
You do this by using the FB JavaScript API and querying if the user is logged in. If it is (to you) it will have your app installed.
I'm trying to get the status from facebook users, who connect to my app with offline_access and read_stream permissions.
All the processes will use subscription to get notification about new feeds, and then take access to status of the user, who changed it.
The code for subscription works great, I get all info as it should be, but the problem starts with second part - every time I try to access user status via
$objFacebook->api('/'USER_ID'/statuses?access_token=TOKEN', 'get', $params);
I get the exception:
An access token is required to request this resource
I tried to set access_token which I got when connected to my website via facebook login, also tried to set the whole session in similar way as it is done here:
Array
(
[access_token] => ...
[base_domain] => ...
[expires] => 0
[secret] => ...
[session_key] => ...
[sig] => ...
[uid] => ...
)
but it didn't help. On the other side, when I copied my access_token generated via facebook developers (http://developers.facebook.com/docs/reference/api/user/) it works correctly, so it looks like my app generates an incorrect access token.
Do you have any idea where the problem can be?
To connect I use facebook-php-2.0 library.
You should upgrade to version 3 of the PHP SDK. We made some changes to the cookie format and other things you can read about here. Version 2 will stop working on September 1st, so you'll need to upgrade soon anyways. Once you've done that, things should work for you.
P.S. You probably will want to use the "/posts" connection rather than than the "/statuses" connection of the User object as it will also give you any posts the user made that include attachments. The "/statuses" connection will only return text-only posts the user made. We'll update the documentation to clarify that.
I would like my canvas application to obtain time-zones of my user's friends.
I tried doing it with the Graph API but all I can get is their names, locales and a few more (even when using the access_token).
When using FQL the timezone field is always empty.
Is there a way to achieve this?
If so, could you please point me in the right direction?
Cheers
I guess this is not possible, only the following fields were retrieved when calling $this->facebook->api("/friend_ID");:
Array
(
[id] =>
[name] =>
[first_name] =>
[last_name] =>
[link] =>
[gender] =>
[locale] =>
[updated_time] =>
)
Now in the documentation, the above fields are the fields marked Publicly available, in time the timezone field is Available to everyone on Facebook which sounds like the same but apparently it's not, anyway I've found this interesting article for a moderator on the facebook forums (not a developer!!)
Also tried the old rest lib, first get a list of your friends from the console and then add your ID and put them in the test console of the users.getinfo method, UIDs looks like your_id,friend_id,friend_id,friend_id,friend_id and fields timezone you'll only get your timezone.