Google AndroidPublisher Subscriptions acknowledge how to - php

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');

Related

Facebook Conversions API - AuthorizationException (Invalid parameter)

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)

How to connecting firebase from php?

Hello i am trying to make connection to firebase database from php and i have this code
<?php
require __DIR__.'/vendor/autoload.php';
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__ . '/secret/sajilo-entrance-med-firebase-adminsdk-1bta4-487ebfe276.json');
$factory = (new Factory)->withServiceAccount($serviceAccount);
$firebase = (new Factory)
->withServiceAccount('$serviceAccount')
->withDatabaseUri('https://sajilo-entrance-med.firebaseio.com/')
->create();
$database = $firebase->getDatabase();
?>
and i am getting this error
Fatal error: Uncaught TypeError: Argument 1 passed to Kreait\Firebase\Factory::withServiceAccount() must be an instance of Kreait\Firebase\ServiceAccount, string given, called in C:\xampp\htdocs\MedEntrance\dbconfig.php on line 10 and defined in C:\xampp\htdocs\MedEntrance\vendor\kreait\firebase-php\src\Firebase\Factory.php:77 Stack trace: #0 C:\xampp\htdocs\MedEntrance\dbconfig.php(10): Kreait\Firebase\Factory->withServiceAccount('$serviceAccount') #1 C:\xampp\htdocs\MedEntrance\insert_test.php(43): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\MedEntrance\vendor\kreait\firebase-php\src\Firebase\Factory.php on line 77
Try change withServiceAccount('$serviceAccount') to withServiceAccount($serviceAccount)

PHP Error SoapClient getProxy()

Getting this error while using soap service php :
Fatal error: Uncaught SoapFault exception: [Client] Function ("getProxy") is not a valid method for this service in C:\webserver\www\feeder\index.php:7 Stack trace: #0 C:\webserver\www\feeder\index.php(7): SoapClient->__call('getProxy', Array) #1 C:\webserver\www\feeder\index.php(7): SoapClient->getProxy() #2 {main} thrown in C:\webserver\www\feeder\index.php on line 7
here's my code :
<?php
$wsdl = "http://localhost:8182/fg/live.php?wsdl";
$username = "aaaaa";
$password = "123456";
$client = new SoapClient($wsdl);
$proxy = $client->getProxy();
$token = $proxy->GetToken($username, $password);
var_dump("Get Token = ".$token);
$table = $proxy->ListTable($token);
var_dump("Tabel = ".$table);
?>
There's something wrong with my code ?
Please have a look at the PHP SoapClient Doku, there is no getProxy-Method. The client itself calls the functions defined in wsdl:
$token = $client->GetToken();
$client->ListTable($token);
And make shure, that you check $token, if it's really a single variable, or if it is an object.

search Google Calendar extendedProperties

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.

Problem while executing Facebook query

I am trying to run a FQL for the first time. This is the code I have included in my index.php file:
<?php $query="SELECT message FROM status WHERE uid = 544337058";echo $query; ?>
<?php
include_once ('facebook.php');
$api_key = 'XXXXXXXXXXXXXXX';
$secret = 'XXXXXXXXXXXXXXXXX';
global $facebook;
$facebook = new Facebook($api_key, $secret);
$result = $facebook->api_client->fql_query($query);
?>
<?php echo $result?>
I have logged into facebook from a different tab and just trying to read my own status message. However I am getting the following error:
SELECT message FROM status WHERE uid = ######
Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Requires
user session' in /users/home/aafhe7vh/web/public/facebookapi_php5_restlib.php:3065 Stack
trace: #0 /users/home/aafhe7vh/web/public/facebookapi_php5_restlib.php(1025):
FacebookRestClient->call_method('facebook.fql.qu...', Array) #1 /users/home/aafhe7vh
/web/public/status.php(46): FacebookRestClient->fql_query('SELECT message ...') #2 {main}
thrown in /users/home/aafhe7vh/web/public/facebookapi_php5_restlib.php on line 3065
How do I get and provide a user's session to this query.
Thanks.
Try putting require_login method after $facebook object eg it should be like:
$facebook = new Facebook($api_key, $secret);
$facebook = $facebook->require_login();
If it is facebook application which it seems to be, also put this line below require_login:
$facebook = $facebook->require_frame();

Categories