Facebook Marketing API connections: exclude people - facebook

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:

Related

mojolicious need all the time out time for load a page on production with hypnotoad

There is one page on my Mojolicious project that loads correctly but then the connections doesn't finish until arrive to the timeout time.
I got the problem only with hypnotoad on production server.
I couldn't replicate the problem on development.
I have been one day investigating the issue due the page was doing and api request to an external service.
Initially I was thinking it was due to some Mojo::UserAgent problem and I have been trying multiple combinations of Promise and IOLoop and anyone was working.
the code simplified is:
sub show {
my $s = shift;
my $customer = Model::Customers->new();
$customer->id( $s->session('id') );
$customer->get();
my $subscription = Model::Customers::Subscriptions->new();
$subscription->id( $s->session('id') );
$subscription->get();
my $plan = Model::Plans->new();
$plan->id( $subscription->idPlan );
$plan->get;
$s->stash(
namePlan => $plan->name,
monthDuration => $plan->monthDuration,
amount => $plan->amount,
end => $subscription->end,
status => $subscription->status,
signupDate => $customer->signupDate,
endTrial => $customer->endTrial,
diffTrial => $customer->diffTrial,
trialDays => $customer->trialDays,
startSubscription => $subscription->start,
discount => $plan->discount,
newsletter => $newsletter,
);
$s->render();
}
I don't share template code because isn't necessary.
The page and template load correctly but the browser, chrome, stay loading until arrive to the timeout. (15s default)
The reason of the problem is that I was using a reserved stash word 'status'.
The solution is change the name of the variable on stash and in the template:
$s->stash(
namePlan => $plan->name,
monthDuration => $plan->monthDuration,
amount => $plan->amount,
end => $subscription->end,
subStatus => $subscription->status,
signupDate => $customer->signupDate,
endTrial => $customer->endTrial,
diffTrial => $customer->diffTrial,
trialDays => $customer->trialDays,
startSubscription => $subscription->start,
discount => $plan->discount,
newsletter => $newsletter,
);

Perl using USAePay billing module

I was wondering if anybody has experience using the USAePay billing module? I have reached out to the developer and his response was he does not have time to help people. My problem is this -
I have written the following code to add a customer's billing information using the Sandbox server but it looks as though the module defaults to the production server so each time I attempt to validate the transaction I get the response -
Card was rejected: Specified source key not found.
How do I tell it to use the Sandbox server?
use strict;
use warnings;
use Business::OnlinePayment;
use constant {
LOGIN => 'source key', #USAePay source key
PASSWORD => '12345', #USAePay PIN
};
my $tx = new Business::OnlinePayment("USAePay");
$tx->content(
login => LOGIN,
password => PASSWORD,
type => 'CC',
action => 'Recurring Authorization',
description => 'Business::OnlinePayment test',
amount => '49.95',
invoice_number => '100100',
name => 'Tofu Beast',
card_number => '4000100011112224',
expiration => '09/19',
address => '1234 Bean Curd Lane',
city => 'San Francisco',
state => 'CA',
zip => '94102',
);
$tx->submit();
if($tx->is_success()) {
print 'Card processed successfully: '.$tx->authorization.'\n';
} else {
print 'Card was rejected: '.$tx->error_message."\n";
}
As Business::OnlinePayment::USAePay is a processor for Business::OnlinePayment, but doesn't have a lot of docs itself, a look at the docs of Business::OnlinePayment might help. It reveales the test_transaction method.
Most processors provide a test mode, where submitted transactions will not actually be charged or added to your batch, calling this function with a true argument will turn that mode on if the processor supports it, or generate a fatal error if the processor does not support a test mode (which is probably better than accidentally making real charges).
An untested example:
my $tx = new Business::OnlinePayment("USAePay");
$tx->test_transaction; # here
$tx->content(
login => LOGIN,
password => PASSWORD,
type => 'CC',
action => 'Recurring Authorization',
description => 'Business::OnlinePayment test',
amount => '49.95',
invoice_number => '100100',
name => 'Tofu Beast',
card_number => '4000100011112224',
expiration => '09/19',
address => '1234 Bean Curd Lane',
city => 'San Francisco',
state => 'CA',
zip => '94102',
);
$tx->submit();
Digging a bit deeper in the source of Business::OnlinePayment::USAePay shows that this particular processor actually has three different test modes.
# test_transaction(0): normal mode
# 1 : test mode (validates formatting only)
# 2 : use sandbox server
# 3 : test mode on sandbox server
It looks like you can set the server details in the constructor - it takes an optional hash of parameters beyond the processor name.
Have you tried something like:
my $tx = new Business::OnlinePayment(
"USAePay",
Server => 'https://sandbox.usaepay.com/gate'
);

Setting up Country Restrictions for Facebook App?

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

Openid - User details after authentication

I am trying to use Catalyst::Authentication::Credential::OpenID to authenticate users from Google.
Once authentication is successful, I get a Catalyst::Plugin::Authentication::User::Hash object as my user.
If users are logging in for the first time in my application, I want to get details of user from OpenID provider and store them in my DB.
This is to ease the process of registration, I want as much details from OpenID as possible.
But at least first name, last name, email etc..
But I am not able to achieve it. As an example, if I call, I get exception saying method *url,display * are not defined.
$c->user->url
$c->user->display
Any help in sorting it out is helpful.
After reading the Catalyst manual a number of times and getting some clue from Catalyst mailing lists, I came to know that we have to use extensions.
Because we will be using a number of different realms, I used progressive class.
Here is sample configuration used in my app, currently supporting only openID.
This uses Simple Registration Schema for OpenID Attribute Exchange defined at
http://www.axschema.org/types/
'Plugin::Authentication' => {
default_realm => 'progressive',
realms => {
progressive => {
class => 'Progressive',
realms => [ 'openid' ],
},
openid => {
credential => {
class => "OpenID",
store => {
class => "OpenID",
},
consumer_secret => "Don't bother setting",
ua_class => "LWP::UserAgent",
# whitelist is only relevant for LWPx::ParanoidAgent
ua_args => {
whitelisted_hosts => [qw/ 127.0.0.1 localhost /],
},
extensions => [
'http://openid.net/srv/ax/1.0' => {
mode => 'fetch_request',
'type.nickname' => 'http://axschema.org/namePerson/friendly',
'type.email' => 'http://axschema.org/contact/email',
'type.fullname' => 'http://axschema.org/namePerson',
'type.firstname' => 'http://axschema.org/namePerson/first',
'type.lastname' => 'http://axschema.org/namePerson/last',
'type.dob' => 'http://axschema.org/birthDate',
'type.gender' => 'http://axschema.org/person/gender',
'type.country' => 'http://axschema.org/contact/country/home',
'type.language' => 'http://axschema.org/pref/language',
'type.timezone' => 'http://axschema.org/pref/timezone',
required => 'nickname,fullname,email,firstname,lastname,dob,gender,country',
if_available => 'dob,gender,language,timezone',
}
],
},
}
}
},

Send notification or post on wall

i have been going crazy and cant figure out how to make a script for my application that would allow the user to select a friend and send them a notification or post on their wall from my application.
I just need to notify their friend that they have been challenged to play a flash games, just a simple text with a link, i dont need anything fancy :D
Here is what i tried and it doesnt work :( no idea why.
$message = 'Watch this video!';
$attachment = array( 'name' => 'ninja cat', 'href' => 'http://www.youtube.com/watch?v=muLIPWjks_M', 'caption' => '{*actor*} uploaded a video to www.youtube.com', 'description' => 'a sneaky cat', 'properties' => array('category' => array( 'text' => 'pets', 'href' => 'http://www.youtube.com/browse?s=mp&t=t&c=15'), 'ratings' => '5 stars'), 'media' => array(array('type' => 'flash', 'swfsrc' => 'http://www.youtube.com/v/fzzjgBAaWZw&hl=en&fs=1', 'imgsrc' => 'http://img.youtube.com/vi/muLIPWjks_M/default.jpg?h=100&w=200&sigh=__wsYqEz4uZUOvBIb8g-wljxpfc3Q=', 'width' => '100', 'height' => '80', 'expanded_width' => '160', 'expanded_height' => '120')));
$action_links = array( array('text' => 'Upload a video', 'href' => 'http://www.youtube.com/my_videos_upload'));
$target_id = $user;
$facebook->api_client->stream_publish($message, $attachment, $action_links, $target_id);
UPDATE:
appinclude.php
$facebook->redirect('https://graph.facebook.com/oauth/authorize?client_id=132611566776827&redirect_uri=https://apps.facebook.com/gamesorbiter/&scope=publish_stream');
Error i get:
{
"error": {
"type": "OAuthException",
"message": "Invalid redirect_uri: The Facebook Connect cross-domain receiver URL (https://apps.facebook.com/gamesorbiter/) must be in the same domain or be in a subdomain of an application's base domain (gamesorbiter.com). You can configure the base domain in the application's settings."
}
}
Without the extra "s"(http) i get this error:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
Please if you could post an example.
Also do i need extended permission to do that or if the user sends the message i dont need that ?
Thank You
Also do i need extended permission to
do that or if the user sends the
message i dont that ?
Yes, you need the offline_access and publish_stream extended permission from the users.
Update:
In your appinclude.php file, put code like this:
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();
$facebook->redirect('https://graph.facebook.com/oauth/authorize?
client_id=[YOUR APP ID]&
redirect_uri=[YOUR APP URL]&
scope=publish_stream, offline_access');
Replace [YOUR APP ID] with application id that you can see from application settings where you created the site in Facebook Developers section. Also replace the [YOUR APP URL] with your app url.