Setting up Country Restrictions for Facebook App? - facebook

I have a problem,
I have a Facebook App which target audience is the US. I want to use Coutnry Restrictions in 'Advanced Settings' so that only people from the US can log into my App.
It appears that whenever I do that, some of my team members ( who are not from the US ), cannot log in into my App... even if they have 'Administrator' role.
How can I allow the 'out of US' developers of my App to still be able to login to it ?
Cheers.

The signed_request has information on country even when the person hasn't logged in.
You can use it to restrict users.
Array ( [algorithm] => HMAC-SHA256 [issued_at] => 1338280574 [page] => Array ( [id] => 171340959572434 [liked] => 1 [admin] => ) [user] => Array ( [country] => in [locale] => en_US [age] => Array ( [min] => 21 ) ) )
OR
You can add multiple countries to allow. so you will have to allow your developers country as well and show some error message by using above method for those developers country people

Related

Facebook Marketing API connections: exclude people

So on the Ads Manager under connections, it gives you the choice to exclude people who used your app as a way to avoid showing ads to your current users.
The marketing API in the doc says you can set a targeting spec: 'app_install_state' which can be set to 'INSTALLED' or 'NOT_INSTALLED' and to quote facebook
must be used in conjunction with promoted_object at adset level
I have tried adding it to the $targeting object as well as adding it on the adset level. But when I go to view the ad set in the ad manager on Facebook the connections part is still unchanged.
'name' => 'Test Ad Set',
'billing_event' => 'APP_INSTALLS',
'optimization_goal' => 'APP_INSTALLS',
'campaign_status' => "PAUSED",
'daily_budget' => 5000,
'bid_amount' => 10,
'campaign_group_id' => $id,
'targeting' => json_encode($targeting),
$targeting = array(
'geo_locations' => array(
'countries' => array('US'),
),
'page_types' => array('mobilefeed'),
'user_os' => array('Android'),
'app_install_state' => 'NOT_INSTALLED',
);
Also tried moving the app_install_state outside of the targeting array to the adset level.
Incase you don't know what am talking about this is the part on the ad manager:

How to get the visitors state information from the tab iframe tab page via signed request?

Is there anyway to get the state information of the user visiting my facebook tab page? Currently via signed request i can get the country information. Is there a way to get state information also??
Answer is NO, check out the documentation here https://developers.facebook.com/docs/authentication/signed_request/
You get data like this
Array (
[algorithm] => HMAC-SHA256
[issued_at] => 1328803958
[page] => Array (
[id] => 114951721840
[liked] => 1
[admin] => 1 )
[user] => Array (
[country] => us
[locale] => en_US
[age] => Array ( [min] => 21 )
)
)

facebook tab userid is 0 after page like

I'm trying to get a the facebook userid in a facebook tab, but somehow this always returns 0.
This is the code I use:
$config = array();
$config["appId"] = "427761887242287";
$config["secret"] = "xxxxxxxxxxxxxxxxxxxxxx";
$facebook = new Facebook($config);
$fbData = $facebook->getSignedRequest();
Facebook appId and secret are valid, I've already tried with resetting the secret.
I've tried to do a print_r on $fbdata but this only returns:
Array
(
[algorithm] => HMAC-SHA256
[issued_at] => 1337603346
[page] => Array
(
[id] => 158282080958121
[liked] => 1
[admin] =>
)
[user] => Array
(
[country] => nl
[locale] => en_US
[age] => Array
(
[min] => 21
)
)
)
As you can see, this retuns only some non usefull data as far as the user goes.
I've also tried $facebook->getUser() but this does return 0.
I do have a valid SSL certificate on my server, I use the right http and https URL's but I can't find out why I get a 0 for the userid while I'm logged in.
Any suggestions?
If this is a facebook page tab application, then the user id is not returned unless the user has explicitly authorized your application. And from the response you've posted it looks like this is the case. You would need to get the user to authorize your application, not just like a page for this to work
https://developers.facebook.com/docs/authentication/pagetab/

facebook signed_request user_id missing

This is data of signed_request:
Array
(
[algorithm] => HMAC-SHA256
[issued_at] => 1331219385
[page] => Array
(
[id] => xxxx602xxx551
[liked] => 1
[admin] => 1
)
[user] => Array
(
[country] => at
[locale] => de_DE
[age] => Array
(
[min] => 21
)
)
)
but user_id is missing ...
is this because user dont gave permission to the app?
I thougt an app can access all data which is public, like name or user_id
is there a way to get "user_id" without a basic permission?
You will not be able to get any identity of user prior to connection with application, this is just not possible.
You need to authorize the user to get his user id

Problems getting monthly active users correctly (via Facebook Graph API)

Hey there!
I'm not able to fetch a reliable monthly active users number of my application. I tried it with FQL:
[...]
$end_time = date('Y-m-d', time()-(60*60*24*2)); // Dont' know what is correct. Sometimes it's *2 sometimes it's working with *3
$fql = $facebook->api(array(
"method" => "fql.query",
"query" => "SELECT metric, value FROM insights WHERE object_id='000000000' AND metric='application_active_users'
AND end_time=end_time_date('".$end_time."')
AND period=period('month')"
));
[...]
Looks like it's not possible to get a value up-to-the-minute. I want to get the same value as stated on my application page. But with this code it's different every day.
I also tried this solution:
$fql = $facebook->api('/000000000/insights/application_active_users/month');
but as response I only get out dated values which are a few days old:
Array
(
[data] => Array
(
[0] => Array
(
[id] => 000000000/insights/application_active_users/month
[name] => application_active_users
[period] => month
[values] => Array
(
[0] => Array
(
[value] => 166345
[end_time] => 2010-12-09T08:00:00+0000
)
[1] => Array
(
[value] => 167679
[end_time] => 2010-12-10T08:00:00+0000
)
[2] => Array
(
[value] => 168983
[end_time] => 2010-12-11T08:00:00+0000
)
)
[description] => Monthly Users who have engaged with your application or viewed your application (Unique Users)
)
)
[paging] => Array
(
[previous] => https://graph.facebook.com/000000000/insights/application_active_users/month?since=1291556506&until=1291815706
[next] => https://graph.facebook.com/000000000/insights/application_active_users/month?since=1292074906&until=1292334106
)
)
What am I doing wrong?
Facebook insights data is not available just-in-time. The insights graph will always display historic data only.
If you are interested for current monthly_active_users number look into the applications table with fql.