I am quite a beginner and trying to learn to apply some things in Facebook PHP SDK, but there are some things poorly explained in the documentation.
My goal is to get number of users who say are interested in both "socker" and "football".
I think a function getReachEstimate($array, $array) does exactly that, my approach would be.
use FacebookAds\Object\ReachEstimate;
use FacebookAds\Object\Fields\ReachEstimateFields;
use FacebookAds\Object\AdAccount;
$account = new AdAccount($account_id);
$reachEstimate = $account->getReachEstimate($SOME_ARRAY, $SOME_ARRAY2));
I looked in the source of SDK and this function takes two arrays, but it is nowhere explained what are these arrays must look like. If anyone has any suggestions, please let me know. Thank you.
The first parameter seems irreverent to me. But I'm not sure. Will update the answer when I find. Meanwhile here's how to do it:
Suppose following are your parameters:
$params = [
'targeting_spec' => ['geo_locations' => ['countries' => ['US']]]
];
$fields = [];
Then call it in the following way:
$adAccount = new AdAccount($adAccountId);
$adAccount->getReachEstimate($fields, $params)->getData();
So, put your Targeting Spec in $params and the calls
Hope this helps!
Related
I followed this docs.
https://lumen.laravel.com/docs/5.5/authorization
Actually I dont know where to define the Gate
in register() or in boot() function
After that also it say: Class 'App\Providers\Gate' not found
And what is the correct one in 3 of these?
Illuminate\Auth\Access\Gate
Illuminate\Support\Facades\Gate
Illuminate\Contracts\Auth\Access\Gate
For the 'Checking Abilities', the docs said :
if (Gate::allows('update-post', $post)) {
But I cannot use that in my route file.
The question here is how to use gate in route?
Please support me. I'm new with this.
Thanks.
you should use this Illuminate\Support\Facades\Gate
**remember** everything that you use trough `::` like Gate::allows or
Route::get or something like that is `Facade` so for import use the uri that
contains `Facade`
Here is good tutorial which explain how to use `Gate`, hope it can be usefull
https://laravel-news.com/authorization-gates
https://code.tutsplus.com/tutorials/gates-and-policies-in-laravel--cms-29780
https://www.grafikart.fr/tutoriels/laravel/gates-policies-867
I am trying to have a REST design, but I am running in a bit of a problem. I have a resource schedule. Therefore, the normal notation of /schedules/{id} is not very applicable since I would like to have /schedules/{day}/{month}/{year} and then apply REST, and have /edit and such.
Is there a way to do this with Route::resource() ? or do I need to do them through Route::get() ?
As far as I know route::resource only gives you the routes that are detailed in the documentation so for what you want you would need to declare your own route. It is still restful and if it is only one of the resourceful routes you want to change you should still be able to do the following because the routes are prioritized in the order they are declared.
Route::get('schedule/{day}/{month}/{year}/edit', array('as' => 'editSchedule', 'uses' => 'ScheduleController#edit'));
Route::resource('schedule', 'ScheduleController');
Yes, there is a very simple way. Here is an example:
Specify your route like this:
Route::resource("schedules/day.month.year", "ScheduleController");
The request will be like this:
/schedules/day/1/month/12/year/2014
And now you can get all three parameters in show method of your
contoller:
public function show($day, $month, $year)
Hi there this might be handy if you want to call your route by name. Also you can use one or multiple parameters. It works with me on laravel 5.1
According to the laravel docs:
http://laravel.com/docs/5.1/routing#named-routes
Route::get('user/{id}/profile', ['as' => 'profile', function ($id) {
//
}]);
$url = route('profile', ['id' => 1]);
This works with Route:resource aswell.
for example:
Route::resource('{foo}/{bar}/dashboard', 'YourController');
Will create named routes like: {foo}.{bar}.dashboard.show
To call this with the route method, you set it up as followed.
route('{foo}.{bar}.dashboard.show', ['foo' => 1, 'bar'=> 2])
Which will create the url yourdomain.com/1/2/dashboard
Ill hope this is usefull.
Pascal
What I like to do:
I am using Rex to remotely call tests at servers. I remotely execute the tests with a call the the local prove. I want to gather all the information about the testruns at the different servers at one place. To achieve this I run the tests with prove -a (and maybe also with --merge for capturing STDERR) to create an archive (.tgz). I then download this archive again with Rex to the controlling server. I think this is quite a good plan so far...
My problem now is that I find a lot of hints on creating such a TAP-archive, but none of how I can actually read this archive. Sure, I could open and process it somehow with Archive::Tar or parse it manually with TAP::Parser as suggested by Schwern. But knowing that there are formatters like TAP::Formatter::HTML or TAP::Formatter::JUnit (e.g. for Jenkins) I think there must be a way of using those tools directly on a TAP-archive? When I look up the docs I only find hints on how to use this stuff with prove to format tests while running them. But I need to use this formatters on the archive, I have been running prove already remotely...
So far about the context. My question in short is: How can I use the Perl-TAP-Tools to format TAP coming from a TAP-archive produced by prove?
I am thankful for any little hints. Also if you see a problem in my approach in general.
Renée provided a working solution here: http://www.perl-community.de/bat/poard/thread/18420 (German)
use strict;
use warnings;
use TAP::Harness::Archive;
use TAP::Harness;
use TAP::Formatter::HTML;
my $formatter = TAP::Formatter::HTML->new;
my $harness = TAP::Harness->new({ formatter => $formatter });
$formatter->really_quiet(1);
$formatter->prepare;
my $session;
my $aggregator = TAP::Harness::Archive->aggregator_from_archive({
archive => '/must/be/the/complete/path/to/test.tar.gz',
parser_callbacks => {
ALL => sub {
$session->result( $_[0] );
},
},
made_parser_callback => sub {
$session = $formatter->open_test( $_[1], $_[0] );
}
});
$aggregator->start;
$aggregator->stop;
$formatter->summary($aggregator);
Tanks a lot! I hope this will help some others too. It seems like this knowledge is not very wide spread yet.
I have made a module to pack this solution in a nice interface: https://metacpan.org/module/Convert::TAP::Archive
So from now on you can just type this:
use Convert::TAP::Archive qw(convert_from_taparchive);
my $html = convert_from_taparchive(
'/must/be/the/complete/path/to/test.tar.gz',
'TAP::Formatter::HTML',
);
The problem with the output is mentioned in the docs. Please provide patches or comments if you know how to fix this (minor) issue. E.g. here: https://github.com/borisdaeppen/Convert-TAP-Archive
Renee pointed me to how Tapper makes it: https://metacpan.org/source/TAPPER/Tapper-TAP-Harness-4.1.1/lib/Tapper/TAP/Harness.pm#L273
Quite some effort to read an archive though...
I'm currently working on a project with Symfony 2 and MongoDB and I'm facing a problem while removing an Embed Document using is ID.
I'm working with Activities. An Activity embed a list of Comment and list of Vote.
A Comment can embed a list of Vote too.
To remove a Comment or a Vote from an Activity I do stuff like that :
$dm = $this->get('doctrine.odm.mongodb.document_manager');
$activity = $dm->getRepository('SocialNetworkActivityBundle:Activity')
->findOneBy(array("votes.id" => $voteId));
$votes = $activity->getVotes();
$targetVote = null;
foreach ($votes as $vote)
if($vote->getId() == $voteId) {
$targetVote = $vote;
break;
}
$activity->removeVote($vote);
$dm->flush();
First of all, I know that the method I use isn't the best so I'm looking for an alternative.
Second of all, I can't use that method to remove a Vote embed in a Comment embed in an Activity, so I'm looking for a way to do that.
I don't find any solution in Doctrine documentation or on Stack (or other forum).
If you have some clues or advises for me I'll be really glad to read about :D
i have this parsed object
$xmlObj = new SimpleXMLElement($XMLToParse, LIBXML_DOTTED_VERSION, FALSE, "http://SOME/schema/universal_v17_0");
that has the stucture like this inside it
<universal:UniversalR LocatorCode="somecode" Version="2" Status="Active">
<common_v17_0:Book Key="some" TravelerType="some">
so i can access the first element(its attributes) like this $VariableX=$xmlObj->UniversalR->attributes();//then $VariableX["Status"];
but when i want access his child i cant $tm=$xmlObj->UniversalR->Book->attributes();
it doesnt want to enter probably because of the different namespace...can any one help me . THX
I found something here http://blog.sherifmansour.com/?p=302
foreach ($xmlObj->UniversalRecord as $entry){
$namespaces = $entry->getNameSpaces(true);
$cmm = $entry->->children($namespaces['common_v17_0']);
$aa=$cmm->Book->attributes();
echo $aa["TravelerType"]."ddddd";
}
That should do it :)
$tm=$xmlObj->UniversalRecord->Book->attributes(); is this typo (UniversalRecord instead of UniversalR) only present in this post or is it also present in your code?
(I'd have liked to post this as a comment.. but it looks like i'm not allowed to, or am too stupid to find the button. :/)