Facebook adgroup creation - Invalid parameter - facebook-ads-api

I am having an issue promoting an unpublished page post via the ads-api.
This was previously working ok for me, but began causing problems yesterday.
I first create an ad_campaign, and then, using the returned campaign_id, I attempt to create an adgroup.
The response from the server is
array(1) {
'error' =>
array(3) {
'message' =>
string(53) "(#100) Invalid parameter: adgroup_spec["campaign_id"]"
'type' =>
string(14) "OAuthException"
'code' => int(100)
}
}
I have verified that I am sending over the correct, newly created campaign_id.
Another point of interest; when I use the UI to delete the ad_campaign afterwards, I am told that I do not have permission to do so. User XXXX does not have permission to access campaign YYYY.
I'm thinking this must be an access_token/permission issue but I'm stumped. The ad objects are created using the user's token, and the unpublished page post is created using the page's access token.
NB: I can provide snippets if needs be, but I'm fairly sure this is a problem with the object creation flow as opposed to a code issue.
Has anyone seen anything similar?
Cheers, Gary
Update with POST data
array(7) {
'campaign_id' =>
int(6013621027457)
'bid_type' =>
int(6)
'bid_info' =>
string(37) "{"clicks":10,"reach":10,"actions":80}"
'conversion_specs' =>
string(66) "{"action.type":"offsite_conversion","offsite_pixel":6013619180457}"
'creative' =>
string(86) "{"type":27,"object_id":407012979370770,"auto_update":false,"story_id":565852233486843}"
'name' =>
string(23) "PropelAd (via PropelAd)"
'targeting' =>
string(95) "{"countries":["IE","AE","GB"],"friends_of_connections":[407012979370770],"page_types":["feed"]}"
}

Yes, it happens to me as well from time to time when uploading ads.
It's very statistical, and it seems to be an off-sync between Facebook servers (the campaign was already successfully uploaded, but the ad-request-handler does not recognize that id).
Wait a few seconds, and try again - after a few shots, it will always work (usually there's no problem, it's pretty rare but happens - and never lasted more than a minute of not-recognizing).
Perhaps it happened more today, due to the general Facebook failures.
I can only assume/hope that Facebook keep track of these errors, and are working on minimizing them by syncing their servers better.

Yep - we are currently putting a lot of time in checking why do ad group fail on unpublished posts - specifically on posts scheduled in the future.
The behavior is very inconsistent. The errors we get are slightly different: "Could not save ad", "Invalid ad creative". The errors are not reported on all ad groups but mostly on one of the ad groups of a whole batch.
We do make sure that the campaign start time is equal or AFTER the time the post is scheduled to.
When we publish the post now and test with the same campaign structure it succeeds (although this also succeeds sometimes on the second try - like it was mentioned here, that the campaign takes some time maybe to become fully valid)
A related bug I opened is here:
https://developers.facebook.com/bugs/593878450648811?browse=external_tasks_search_results_52662e53c59bd2e63625449

Related

GetStream: following feed doesn't return the feed's items

I've followed the 'tour' on GetStream.io and tried to implement the simplest solution, namely creating a feed, uploading an activity, and then following that feed. In my app I have 'users' and 'artists' which can follow one another. I succeeded in creating an activity on artist:1, which shows up (via the API & dashboard) and I succeeded in letting user:1 follow artist:1 (also confirmed via the dashboard).. now comes the problem:
Even though user:1 follows artist:1 and artist:1's feed has items on it, user:1 feeds stays empty.. so it seems following another feed (even though it's successful) doesn't copy the items from source to target feed..even though that's exactly the way it works in the 'tour'.
below is my code (even though it's quite standard)
def test
user_feed = client.feed('user', '1')
artist_feed = client.feed('artist', '1')
artist_feed.get => #returns items
artist_feed.followers => #shows user:1 is a follower
user_feed.get => # nothing?!
end
Am I missing a setting or something? Does anyone have an idea what this could be?
enter image description here
Cheers in advance,
Abel
PS I've added three pictures below of the GetStream dashboard, namely:
You see that artist:1 is followed by user:1
You see that artist:1 has two activities
You see that user:1 has no activities

Laravel 4 - some but not all routes failing on production

I have an application which has been running successfully for over a year on both the production server and my development machine (both running IIS without any pretty URLs). Yesterday I moved the latest in a series of (until now successful) updates from development to production, and since then many of the routes have been failing on the production server, even though they work fine on dev. I've verified that the exact same application and route files are present on both machines, I've confirmed that php artisan routes produce the same output on both machines, I've confirmed that their autoload_classmap.php files are identical, and I've verified that both servers are running Laravel 4.1.23 .
After some testing it appears that, for example, the URL https://localhost/EPHY/index.php/child/3958/edit, which triggers the ChildController::edit() RESTful method on dev, triggers ChildController::create() on production, which then crashes because it can't find the familyId parameter it's expecting. Here's the applicable line in routes.php on both servers:
Route::resource( 'child', 'ChildController', array(
'create' => 'child.create',
'store' => 'child.store',
'show' => 'child.show',
'edit' => 'child.edit',
'update' => 'child.update',
'destroy' => 'child.destroy'
));
I should note that Family, another RESTful resource, works successfully on both servers, but others don't. After doing some more testing, it actually seems like any routes relating to models that have an Eloquent relationship with Family are failing, and all the others are working fine. That's just weird...
Can anybody suggest what may be causing this, or at least where I can look? I'm happy to post additional information.
UPDATE: I continue to poke at this problem, and it's becoming apparent that this is definitely only affecting routes related to models with an Eloquent relationship to the Family model; all other routes in the application appear to be working correctly.
Ok, I figured this out, and it's lame. As I noted above, this was only affecting models which had an Eloquent relationship with Family. What that means in practice is that all of the ::create() methods of the associated Controllers needed the Family::id value. So, here's the code I was checking the determine whether I needed that value from Input::get() or Input::old():
$familyId = ( empty( Input::old() ) )? Input::get('familyId') : Input::old('family_id');
Anybody see the problem? empty() can't take a function call as a parameter. Everything worked fine as soon as I changed the code to:
$familyId = ( Input::old() )? Input::old('family_id') : Input::get('familyId') ;
Now, how did I figure this out? Well, after spending a day and a half assuming I knew what "Can't use function return value in write context" meant, I FINALLY CHECKED THE DAMN ERROR MESSAGE ON GOOGLE! Let this be a lesson to the newbs and a reminder to the veterans, never assume you understand what an error means without double-checking with the groupmind...
I'm so ashamed...

extension development - How to prevent unrelated log entries from showing up in custom log?

Part of this question was already asked here: Joomla >1.7 hide log messages from browser
The Problem:
In my extension, I want to create a custom logger. For that, I do the following:
JLog::addLogger(array(
'text_file' => 'plg_system_myplg.log.php',
JLog::ALL,
array('myplg')
));
and subsequently, to log something:
$log->addEntry(array('comment' => $someMsg, 'level' => $someLogLevel));
My problem is, that in my log file (plg_system_myplg.log.php), some messages completely unrelated to my plugin show up; e.g.:
... NOTICE Can't identify browser version. Agent: ...
or
... INFO FinderIndexerAdapter::getTypeId
The common thing about them is that they get entered without a category.
Initially, I had a single string as last parameter to addLogger; and that, I thought, was the root cause (as described in my solution here:
https://stackoverflow.com/a/22238973/671366). However, even with that fixed (see above the array('myplg'), I see those unrelated log entries being written to my logfile.
Anybody got an idea how to get rid of these superfluous error messages (preferrably by a change in my extension)? Am I doing something wrong in the code shown above? Or is this maybe a Joomla bug?
The only option to fix this at the moment seems to change the Joomla core to log those messages with a category; if I add a category on the addEntry calls for these messages, they don't appear anymore in my logfile!

How to deal with non existent emails

I am making an app that allow to register to a newsletter and then manage it.
There is the normal validation if the field is empty, if is email type, unique ecc..
But how can i check if the email really exists?
If someone enter a fake mail, that mail is entered in the database, and this can mess up the database. And there are other annoyance.
Is possible to check if the mail really exists?
Otherwise it is possible to automatically delete an unregistered user after 10 days?
You can create a rule to check if the e-mail format is valid:
$validator = Validator::make(
Input::all(),
array('email' => 'required|email')
);
if ($validator->fails())
{
return "This is not a valid e-mail";
}
But this will only check for the format (name#domain.tld), because there is no way to know if an e-mail address really exists.
Well... this is not entirely true, there is a way: send an e-mail to that address and if you don't get an error message, the address exists, probably.
The best way to do what you need is, when a user creates an account in your system, send him/her a confirmation e-mail, with a link where he/she should click to validate that address. If the account is not validated for x days you delete it. This is a question that might help you on that: Laravel 4: how to make confirmation email?.
About your last question: create an Artisan Command that checks for unvalidated accounts and delete them. Take a look at the docs, it's easy, Laravel does almost all the job for you. And you can run this command once a day using cron or task manager:
php /var/www/your-site-dir/artisan check:accounts
EDIT:
This question will show you how to create a command: Creating and using Laravel 4 commands
And in the method fire() you should do something like:
public function fire()
{
$dt = Carbon\Carbon::now();
User::where('activated', false)
->where('created_at', '<', $dt->subDays(10))
->delete();
}
There are some APIs you can use to verify the validity and existence of emails, but I am not sure how good they are. The free ones usually limit you to something like 10 an hour which probably would not be nearly enough for you, depending on how busy your site is.
Check out http://verify-email.org/register/levels.html
If you are worried about the sheer amount of emails being entered, you could probably log $_SERVER['REMOTE_ADDR'], which would be the client's IP address in the DB on emails and check to make sure that is unique as well before you save additional records to the table.
As far as how to actually validate the existence and validity of the entered email yourself, I believe you'd have to use fsockopen and issue smtp commands to servers. I did find this php class which attempts to do what we are talking about http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt
I doubt it works, but should get you a nice starting point.

Rails and mongoid: Validation is called on the referenced document upon saving/updating the referrer document?

I have a model Tracker that references_many Users.
Everything works fine, but for some business reasons, sometimes my
Users model are in a situation were often they fails the validation
rules (on purpose).
The problem is that I still need to update my Trackers in parallel of
that. And to my surprise saving the tracker will trigger the
validation rules for my User model as well... and obviously then the
saving of the tracker fails.
I could save my tracker with save :validate => false, but I don't want
to do that I have specific validation rules on the Tracker itself that
I want to be respected.
I also tried to play with deactivating callbacks but could not get it
to work...
Help please !
Alex
Ok, finally figured it out:
references_many :referees, :class_name => "User", :validate => false
This will do the trick !

Resources