How to get incomplete task using asana API in PHP - php

I have to fetch only incomplete task using Asana API
$projectId = 'XXXXXXXXXXX';
$args = array('completed_since' => now);
$tasks = $asana->getProjectTasks($projectId, $args);
$tasksJson = json_decode($tasks);
echo "<pre>"; print_r($tasksJson);
This code fetch all tasks (completed & incompleted tasks) related to that projectId. But I want to fetch seperate incomplete & completed task.

Related

How to get Locations list in Google My Business API | PHP

How can I get locations list in Google My Business API. Where I retrieved account list but I can't figure out how to retrieve location.
Here is my code where I am getting accounts list
define('GOOGLE_CLIENT_ID', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
define('GOOGLE_CLIENT_SECRET', 'XXXXXXXXXXXXX');
// Create Client Request to access Google API
$client = new Client();
$client->setApplicationName('my-app');
$client->setClientId(GOOGLE_CLIENT_ID);
$client->setClientSecret(GOOGLE_CLIENT_SECRET);
$client->setRedirectUri('https://example.com/callback');
$client->addScope('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/business.manage');
$client->setAccessType('offline'); // offline access
$client->setIncludeGrantedScopes(true); // incremental auth
$client->setAccessToken($accessToken);
$service = new \Google_Service_MyBusinessAccountManagement($client);
$accounts = $service->accounts->listAccounts()->getAccounts(); // get accounts
To get google locations,
you can use this PHP My Business file to make things little easier.
First change you scope to ttps://www.googleapis.com/auth/plus.business.manage then include the file and create a object of Google_Service_MyBusiness with you client and then do like this.
$mybusinessService = new Google_Service_MyBusiness($client);
// Get the first account in the accounts array
$accounts = $mybusinessService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
$account = $accountsList[0];
// Get the first location in the locations array
$locations = $mybusinessService->accounts_locations;
$locationsList = $locations->listAccountsLocations($account->name)->getLocations();
$location = $locationsList[0];
var_export($location);
With this process you can also able to get google reviews.
For more details check this Google Business API documentation.
Hope it can help
"It's correct!!!
I increase this at my code:
$optParams = array(
'readMask' => 'name',
);
$list_accounts_response = $my_business_account->accounts_locations->listAccountsLocations("accounts/114893266195214446586", $optParams);
var_dump($list_accounts_response);
Thank you.."
source : https://github.com/googleapis/google-api-php-client/issues/2213#issuecomment-1042785983

Facebook API (PHP) : Get Full Ads List

I am using Facebook API to fetch the full Ads list.
The Code is working, But it return only 25 Ad in case of i have 150+ Ad in my account.
I guess that happens because of the query limits on the Facebook API.
My Code:
$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$account->read();
$fields_adset = array(
AdSetFields::ID,
AdSetFields::NAME,
AdSetFields::CAMPAIGN_ID,
AdSetFields::STATUS,
);
$ads = $account->getAds($fields_adset);
foreach ($ads as $adset) {
$adset_id = $adset->{AdSetFields::ID};
echo $adset_id;
//print_r($adset);
//exit();
}
So, they mentioned in the documentation that :
Use Asynchronous Requests to query a huge amount of data
Reference (1) : https://developers.facebook.com/docs/marketing-api/best-practices/
Reference (2) : https://developers.facebook.com/docs/marketing-api/insights/best-practices/#asynchronous
But, I can't apply that "Asynchronous" requests to my code to fetch the Full Ad List,
Please help me to fetch the full Ads list
Thank you.
You should implement pagination (or request a limit more high). With the PHP SDK you can implement the cursor as described in the doc here or more simply set the Implicit Fetching, as example:
..
use FacebookAds\Cursor;
...
Cursor::setDefaultUseImplicitFetch(true);
$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$account->read();
$fields_adset = array(
AdSetFields::ID,
AdSetFields::NAME,
AdSetFields::CAMPAIGN_ID,
AdSetFields::STATUS,
);
$ads = $account->getAds($fields_adset);
foreach ($ads as $adset) {
$adset_id = $adset->{AdSetFields::ID};
echo $adset_id;
//print_r($adset);
//exit();
}
Hope this help

How to create local post on google using PHP MyBusiness API?

I want to create local post on google using google's PHP My Business API V4.
Sample code is below
$mybusinessService = new \Google_Service_MyBusiness($client);
$local = new \Google_Service_MyBusiness_LocalPost();
$path = $locname.'/localPosts';
$response = $mybusinessService->accounts_locations_localPosts->create($path,$local);
where $locname is string of accounts/locations id.
above code throws exception 'Request contains an invalid argument.'
I want to know that how to create post or post data using PHP api.
Any help would be appreciated.
For brands that have more than ten locations are not allowed to post on GMB through the API. Pull the location and check this flag $location->getLocationState()->getIsLocalPostApiDisabled().
Posting on GMB Ex.
$posts = $mybusinessService->accounts_locations_localPosts;
$newPost = new Google_Service_MyBusiness_LocalPost();
$newPost->setSummary("Order your Thanksgiving turkeys now!!");
$newPost->setLanguageCode("en-US");
$calltoaction = new Google_Service_MyBusiness_CallToAction();
$calltoaction->setActionType("ORDER");
$calltoaction->setUrl("http://google.com/order_turkeys_here");
$newPost->setCallToAction($calltoaction);
$media = new Google_Service_MyBusiness_MediaItem();
$media->setMediaFormat("PHOTO");
$media->setSourceUrl("https://www.google.com/real-turkey-photo.jpg");
$newPost->setMedia($media);
$listPostsResponse = $posts->create($location_name, $newPost);

How to get reviews in Bright Local API

I'm working on Bright Local API ( https://tools.brightlocal.com/ ) to get reviews of a business from Yelp ,Google+ etc.
I got some code of this API from GitHub with some examples.So I just register a free account in Bright Local and try those examples to get Reviews.
Below code is used to fetch the reviews of some business.After running this code i got a job id.But I dont know how to get reviews using this Job id.
$profileUrls = array(
'https://plus.google.com/114222978585544488148/about?hl=en',
'https://plus.google.com/117313296997732479889/about?hl=en',
'https://plus.google.com/111550668382222753542/about?hl=en'
);
// setup API wrappers
$api = new Api(API_KEY, API_SECRET, API_ENDPOINT);
$batchApi = new BatchApi($api);
// Step 1: Create a new batch
$batchId = $batchApi->create();
if ($batchId) {
printf('Created batch ID %d%s', $batchId, PHP_EOL);
// Step 2: Add review lookup jobs to batch
foreach ($profileUrls as $profileUrl) {
$result = $api->call('/v4/ld/fetch-reviews', array(
'batch-id' => $batchId,
'profile-url' => $profileUrl,
'country' => 'USA'
));
if ($result['success']) {
printf('Added job with ID %d%s', $result['job-id'], PHP_EOL);
}
}
// Step 3: Commit batch (to signal all jobs added, processing starts)
if ($batchApi->commit($batchId)) {
echo 'Committed batch successfully.'.PHP_EOL;
}
}
Anybody knows how to get reviews using this API ?
Thanks in advance.
It looks like you're missing the final step which is to poll for results. Our system works by adding jobs to a queue and then processing those jobs in parallel. Having created a batch, added jobs to that batch and committed it you then need to set up a loop, or come back and check for results periodically, until you see that the batch is marked as "Finished" and all jobs have returned data.
To do this call:
$results = $batchApi->get_results($batchId); // repeat this call until complete
$results will contain "status" which will be marked as "Finished" once all jobs have finished processing as well as the actual results associated with each job.

Get users details in mixpanel api

I'm trying to get user details via Mixpanel analytics but I am having difficulties to properly grasp how i should do this… data has been set using
mixpanel.people.identify()
Events and Segmentation requests seem to be ok; but I can't figure out how to query a request on the Engage endpoint.
as it turns out—there might be other ways to find this out but this one works for me:
you need to get engagement data this way
$data = $mp->request(array('engage'));
foreach($data->results as $user) {
$email = $user->{'$properties'}->{'$email'};
$last_seen_date = $user->{'$properties'}->{'$last_seen'};
$distinct_id = $user->{'$distinct_id'};
}
the distinct_id can then be used within the foreach() loop above to get events registered with this user:
$endpoint = array('stream', 'query');
$parameters = array(
'distinct_ids' => json_encode(array($distinct_id)),
'from_date' => '2014-02-10',
'to_date' => '2014-02-25',
);

Categories