Google calendar API V3 update event - php

I can perfectly add an event with Google Calendar API V3 as described in https://developers.google.com/google-apps/calendar/recurringevents but I can't figure how to start on the update event process.
I guess I have to select the event (I do have the event ID stored on my DB) and then set the parameters and call an update event. But don't know where to start...
There seems to be very few tutorials around. Any ideas please?

Ok I finally got the answer my self. Struggled to read on those Google API Explorer and matching them against the google-api-php-client. Anyway, here it is a simple code to update the description, summary and event color.
$apiClient = new apiClient();
$apiClient->setUseObjects(true);
$service = new apiCalendarService($apiClient);
$events = $service->events;
$currEvent = $events->get("primary", $event_id);
$currEvent->setDescription("YOUR FULL DESCRIPTION");
$currEvent->setSummary("YOUR DESIRED SUMMARY - Kind of title");
$currEvent->setColorId(2); // One of the available colors ID
$recurringEvent = $events->update('primary', $event_id, $currEvent);
Remember that this code needs to be ran only after authentication.
Hope it helps someone. It did me ;)

Related

Stripe webhook: can get event ID but not type

In my webhook when I put $event_id = $event_json->id; I get the event id (example: id:evt_1EJ1NdIcP22cq9aQWsTXf8DY).
However, when I put $event_type = $event_json->type; I am expecting to get
charge.succeeded or charge.failed, instead I am getting customer.source.created.
I've searched the internet up and down, can't find the answer. What should I use to get what type of charge it was (charge.succeeded or charge.failed). Maybe this great community can help me solve this one.

Laravel 5 Facebook insights: How to get pageImpressions?

I am using jonasva's laravel facebook insights package ( https://github.com/jonasva/laravel-facebook-insights).
And stuck at the very beginning. So if someone is familiar and can help me out.
I have setup the facebook-insights.php with all the information that is needed. (AppID, Secret, ermanent access token ...)
However, when I try to get the PageTotalImpressions I receive the number 0
FacebookInsightsController:
//Get Facebook PageImpressions
public function getPageImpressions() {
$startDate = new \DateTime('2017-01-01');
$endDate = new \DateTime('2017-03-26');
// fetch your page's total impressions for a given period
$totalImpressions = FacebookInsights::getPageTotalImpressions($startDate, $endDate);
return $totalImpressions;
}
I know that there are Impressions, as Facebook Insights shows different numbers.
Any idea what's wrong here ?
thanks
I just tried using this package myself, I stopped and removed it before even delving in.
On the composer install it states that it loaded php-sdk-v4 which has been abandoned jonasva's laravel facebook insights package has not been updated for over 2 years.
I recommend you do the same as me and begin searching for a new package.

Facebook Ads - update url_tags

I am using Facebook Ads SDK v2.6.0 and I would like to update the url_tags of an Ad.
$ad->creative['id'] contains the AdCreative's ID and is OK since read() returns actual data.
$creative = new AdCreative($ad->creative['id']);
$creativeData = $creative->read([
'link_url',
'name',
'object_story_spec',
'object_story_id',
'url_tags'
]); // $creativeData->url_tags is OK and contains tags we have now
$creative->setData(['url_tags' => "a=b&c=d"]);
$creative->update();
Then everything seems to work fine, the response is received and the result is {"success": true}.
No exceptions are thrown and everything goes smooth, but the url_params is updated neither in Facebook Ads Manager nor the field $creativeData->url_tags when I run the script again.
P.S. I was able to update the object_story_spec of AdCreative, but I would precisely since it wouldn't cause the ad to be re-approved.
Best regards, Alexander
It looks like url_tags are not one of the mutable fields of an AdCreative object, so you will have to re-create the creative with the new url_tags in order to achieve this.
The following section of the docs outlines which fields are mutable:
https://developers.facebook.com/docs/marketing-api/reference/ad-creative#Updating

facebook api marketing create campaign issue

I would like to create a campaign using Facebook API. I tried to run all available example without success.
First of all I created an App in order to have a APP_ID and a APP_SECRET.
I did all the procedure to add my Ad_account following the tutorial.
I downloaded all the SDK to facilitate Facebook API use like:
facebook-php-ads-sdk and run adgroup_creation.php and curl_log.php with my data, without success.
facebook-php-sdk-v4 I suppose it is less specific than the previous one.
Multi-Product Ads with the Facebook Marketing POST -> developers.facebook.com/ads/blog/post/2015/03/26/creating-multi-product-ads/
the developers reference -> developers.facebook.com/docs/reference/php/4.0.0
I used "Composer" to get all dependency.
In all this case I had problem to create a campaign using more or less this code:
$campaign = new \FacebookAds\Object\AdCampaign(null,"act_$ACCOUNT_ID");
$campaign->setData(array(
AdCampaignFields::NAME => 'My First Campaign',
AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS,
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED ));
// PROBLEM is Here
$campaign->create();
Any help? How can I get a more useful error?
It's difficult to help without knowing the exact error. However, you could try this: before creating your campaign, initialize the API using:
Api::init(<your_app_id>, <your_ap_secret>, <your_token>);
(You need to load FacebookAds\Api to use this function).

Modifying budget of an AdWord Campaign by using API

I am implementing adword api version 201306 in one of my project. I am able to fetch the details of a campaign but unable to retrieve the budget details.
My goal is to access the budget details and modify them. I am using PHP library and request to all of you a piece of code written in php.
Any help would be highly appreciated.
Thanks,
Pramod
I found the solution and here is the way you need to go out - -
First you need to pass out the field 'BudgetId' in Campaign Service selector for CampaignStats.
Now you can use following code - -
$budgetService = $user->GetService('BudgetService', ADWORDS_VERSION);
$bm = new Money('10000000');
$campaign->budget->amount = $bm;
$boperation = new BudgetOperation();
$boperation->operand = $campaign->budget;
$boperation->operator = 'SET';
$budgetService->mutate($boperation);
Yes, I agree that this help is very less. Do let me know if anyone face any issue OR need more help.
Regards,
Pramod

Categories