While triggering the Purchase event after a successful transaction on the payment gateway and a redirection to the website, I'm getting the following error:
Fatal error: Uncaught FacebookAds\Http\Exception\AuthorizationException: Invalid parameter in /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php:174 Stack trace: #0 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Client.php(215): FacebookAds\Http\Exception\RequestException::create(Object(FacebookAds\Http\Response)) #1 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Request.php(286): FacebookAds\Http\Client->sendRequest(Object(FacebookAds\Http\Request)) #2 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Api.php(165): FacebookAds\Http\Request->execute() #3 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Api.php(214): FacebookAds\Api->executeRequest(Object(FacebookAds\Http\ in /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php on line 174
Other events being triggered without any issues with a valid Pixel ID and a token.
$this->api = Api::init($pixel_id, null, $access_token);
$event = (new Event())
->setActionSource(ActionSource::WEBSITE)
->setEventName('Purchase')
->setEventTime(time())
->setEventSourceUrl($current_url)
->setUserData($user_data);
$events = array();
array_push($events, $event);
$request = $this->create_request($events);
// Execute the request
$response = $request->execute();
I had the same problem but found out that the reason to the exception is that a purchase event must have currency and value set.
$customData = (new CustomData())
->setCurrency('USD')
->setValue(10);
Then add the custom data to the event:
->setCustomData($customData)
Related
I created a subscription for my Android app and here's my code to confirm subscription assignments, but I get an error
$packageName = "com.example.srkn";
$productId = "com.example.srkn.aylik";
$token = "<some token here>";
require 'vendor/autoload.php';
$client = new \Google_Client();
$client->setAuthConfig('ts.json');
$client->addScope('https://www.googleapis.com/auth/androidpublisher');
$service = new \Google_Service_AndroidPublisher($client);
$postBody = "okey";
$para = "test";
$purchase = $service->purchases_subscriptions->acknowledge($packageName, $productId, $token,$postBody,$para);
//echo json_encode($purchase);
Fatal error: Uncaught TypeError: Argument 4 passed to
Google_Service_AndroidPublisher_Resource_PurchasesSubscriptions::acknowledge()
must be an instance of
Google_Service_AndroidPublisher_SubscriptionPurchasesAcknowledgeRequest,
string given, called in /home/serkanka/public_html/dgr/onayla.php on
line 17 and defined in
/home/serkanka/public_html/dgr/vendor/google/apiclient-services/src/Google/Service/AndroidPublisher/Resource/PurchasesSubscriptions.php:40
Stack trace: #0 /home/serkanka/public_html/dgr/onayla.php(17):
Google_Service_AndroidPublisher_Resource_PurchasesSubscriptions->acknowledge('com.text.spec.s...',
'com.text.spec.s...','jlkehndmfjoaenc...', 'test', 'test') #1 {main}
thrown in
/home/serkanka/public_html/dgr/vendor/google/apiclient-services/src/Google/Service/AndroidPublisher/Resource/PurchasesSubscriptions.php
on line 40
The postbody (4th parameter) should be an instance of Google_Service_AndroidPublisher_SubscriptionPurchasesAcknowledgeRequest
You can set the developerPayload on the object like so:
$requestBody = new Google_Service_AndroidPublisher_SubscriptionPurchasesAcknowledgeRequest();
$requestBody->setDeveloperPayload('your_developer_payload');
I'm struggling to update an event on google calendar. I'm using google-api-php-client. I want to update description of one event at a time using following code.
my#gmail.com is my primary account.
$currEvent = $service->events->get("my#gmail.com", $event_id);
$currEvent->setDescription("Test DESCRIPTION");
$service->events->update("my#gmail.com", $currEvent->getId(), $currEvent);
I'm using above code to update.
Get event is returning proper result but update event is throwing following error:
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling PUT https://www.googleapis.com/calendar/v3/calendars/my%40gmail.com/events/d6ao1oaiaa7s0aif229btheiv4?key=AIzaSyBQJ2hQzpYn8UIL97VKkg3tBFTq9nFAQUE: (403) Forbidden' in /google-api-php-client/src/Google/Http/REST.php:76 Stack trace: #0 /google-api-php-client/src/Google/Http/REST.php(41): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request)) #1 /google-api-php-client/src/Google/Client.php(548): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request)) #2 /google-api-php-client/src/Google/Service/Resource.php(190): Google_Client->execute(Object(Google_Http_Request)) #3 / in /google-api-php-client/src/Google/Http/REST.php on line 76
I've tried adding an event to google calendar using following code and it's working:
$event = new Google_Service_Calendar_Event();
$event->setSummary('Appointment');
$event->setLocation('test location');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2014-12-12T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2014-12-12T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('abc#test.com');
// ...
$attendees = array($attendee1);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
echo $createdEvent->getId();
Any help is most appreciated.
Cheers!!!
I am trying to insert an event with Google Calendar API and PHP. Everytime I submit my form I get the below error message:
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling POST https://www.googleapis.com/calendar/v3/calendars/{{MY-CALENDAR-ID-IS-HERE}}#group.calendar.google.com/events: (404) Not Found' in /Applications/MAMP/htdocs/dl-home/classes/google-api/io/Google_REST.php:66 Stack trace: #0 /Applications/MAMP/htdocs/dl-home/classes/google-api/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 /Applications/MAMP/htdocs/dl-home/classes/google-api/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 /Applications/MAMP/htdocs/dl-home/classes/google-api/contrib/Google_CalendarService.php(469): Google_ServiceResource->__call('insert', Array) #3 /Applications/MAMP/htdocs/dl-home/includes/add-memo.php(66): Google_EventsServiceResource->insert('56c1bc787c21b50...', Object(Google_Event)) #4 {main} thrown in /Applications/MAMP/htdocs/dl-home/classes/google-api/io/Google_REST.php on line 66
But I dont understand what the problem is, I have my Client ID, Calendar ID and Service Email in my script, I also made sure that the sharing permissions of my calendar are shared to my service email but still no luck. I did find similar issues here and here but those havent helped. I also have review the php sample library prior to asking :)
Here is my script:
session_start();
//Call-in the google client library
require_once '../classes/google-api/Google_Client.php';
require_once '../classes/google-api/contrib/Google_CalendarService.php';
//Service and Client Acc Details
define('CLIENT_ID', '890699386256-mdpm4jr22iu6p6j4mi0bvlpgq602ri7g.apps.googleusercontent.com');
define('SERVICE_ACCOUNT_NAME', '890699386256-mdpm4jr22iu6p6j4mi0bvlpgq602ri7g#developer.gserviceaccount.com');
define('KEY_FILE', '../components/DL-Calendarapi-0a09ec997f6a.p12');
//New Session Open / Set Access Token
$client = new Google_Client();
$client->setApplicationName("Anything-here");
$client->setUseObjects(true);
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
//Set Key Cred Details
$key = file_get_contents(KEY_FILE);
$client->setClientId(CLIENT_ID);
$client->setAssertionCredentials(new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
'https://www.google.com/calendar/feeds/56c1bc787c21b501a73c1e7e5776560f/private/full/',
$key)
);
//Format the date to be 'friendly' with the google event input format
//This takes dates as dd/mm/yyyy and converts to yyyy-mm-dd
$df = DateTime::createFromFormat("d/m/Y", $_GET['dateFrom']);
$dt = DateTime::createFromFormat("d/m/Y", $_GET['dateTo']);
$datet = new DateTime($dt->format("Y-m-d"));
//Custom modify snippet to fix googles timezone error
$datet->modify('+1 day');
$client->setClientId(CLIENT_ID);
$cal = new Google_CalendarService($client);
//Create the event (Adding Details)
$event = new Google_Event();
//Event title set..
$event->setSummary($_GET['name']);
$event->setLocation('Anything-here-or-pass-variable');
$event->setDescription($_GET['comment']);
$start = new Google_EventDateTime();
$start->setDate($df->format("Y-m-d"));
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDate($datet->format("Y-m-d"));
$event->setEnd($end);
//Add the Event object to Calendar
$cal->events->insert('56c1bc787c21b501a73c1e7e5776560f#group.calendar.google.com', $event);
//Show success message
echo '<div id="message"><div id="message-body"><p>Event Created!</p></div></div>';
The scope seems wrong: 'https://www.google.com/calendar/feeds/56c1bc787c21b501a73c1e7e5776560f/private/full/'
For API v3 you need to use 'https://www.googleapis.com/auth/calendar'
I have the following problem when doing a privateExtendedProperty search
$service = new Google_CalendarService($client);
$extendedProperties = New Google_EventExtendedProperties();
$param = array();
$param['singleEvents'] = false;
$param['extendedProperties'] = "CodeID=66";
$events = $service->events->listEvents($calendarioId,$param);
Fatal error:
Uncaught exception 'Google_Exception' with message '(list) unknown parameter: 'extendedProperties'' in
..\google\service\Google_ServiceResource.php:111
Stack trace:
#0 ...\includes\google\contrib\Google_CalendarService.php(529): Google_ServiceResource->__call('list', Array)
#1 ...\google_calendario.php(198): Google_EventsServiceResource->listEvents('hude3h3fjolua08...', Array)
#2 ..\google_calendario.php(442): c_googlecalendario->proc_google('hude3h3fjolua08...', '66')
With the latest api on github you can do this:
$events = $service->events->listEvents($calendarId, array('privateExtendedProperty'=>'codeID='.$yourId));
Pay attention that it's either privateExtendedProperty or sharedExtendedProperty depending on how you created the event.
I have my application authenticated using OAuth - and I've tested it with the calendar API. Everything works. I also used the "quick add" method for the events API, and that worked fine. But when I tried to insert using the following code
$event = new Event();
$event->setSummary('hello there');
$event->setLocation('America/Los_Angeles');
$start = new EventDateTime();
$start->setDateTime('2012-04-19');
$event->setStart($start);
$createdEvent = $cal->events->insert('myemail#gmail.com', $event);
I get the following error:
Fatal error: Uncaught exception 'apiServiceException' with message
'Error calling POST
https://www.googleapis.com/calendar/v3/calendars/myemail#gmail.com/events?key=AIzaSyBddYIgnZJrXHuT8gvX-0tEypxsycw99rA:
(400) Bad Request' in
C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php:86 Stack
trace: #0
C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php(56):
apiREST::decodeHttpResponse(Object(apiHttpRequest)) #1
C:\xampp\htdocs\uis\google-api-php-client\src\service\apiServiceResource.php(187):
apiREST::execute(Object(apiServiceRequest)) #2
C:\xampp\htdocs\uis\google-api-php-client\src\contrib\apiCalendarService.php(493):
apiServiceResource->__call('insert', Array) #3
C:\xampp\htdocs\uis\google-api-php-client\examples\calendar\cal.php(44):
EventsServiceResource->insert('paine1591#gmail...', Object(Event)) #4
{main} thrown in
C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php on line
86
with myemail#gmail.com being the ID of my calendar. It works for everything else.
What am I doing wrong?
It appears that you're not setting the attendees of the event.
Example:
$end = new EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->end = $end;
$attendee1 = new EventAttendee();
$attendee1->email = 'attendeeEmail';
$attendees = array($attendee1, ...);
$event->attendees = $attendees;