I'm using the theiconic/php-ga-measurement-protocol package and have followed the exact steps as described in the readme, but for reasons I don't quite understand, half of the info does not show up in Google Analytics.
I'm using the following code:
use TheIconic\Tracking\GoogleAnalytics\Analytics;
$trackingID = 'xxxxxxx';
$order = 'obviously an object';
$deal = 'object';
$analytics = new Analytics();
// the Client ID just won't do anything
$analytics->setProtocolVersion('1')
->setClientId($order->gaClientID)
->setTrackingId($trackingID);
// this part works just fine
$analytics->setTransactionId($transactionID)
->setRevenue($order->getTotalPrice(false))
->setTax($order->getTaxCost())
->sendTransaction();
// here it's as if nothing happens
// Yes, it does loop over all the orderRules but it does not show up in Google Analytics
foreach ($order->getOrderRules() as $orderRule) {
$analytics->setTransactionId($transactionID)
->setItemName($deal->name)
->setItemCode($order->dealID)
->setItemCategory($deal->getDealCategoryName())
->setItemPrice($orderRule->getPrice())
->sendItem();
}
And I'm saving the ClientID with this JavaScript into a hidden input:
ga.getAll()[0].get('clientId')
So my issues are basically:
client ID does not work
Items do not appear in Google Analytics Ecommerce
Is there anything I am forgetting? I've had several people looking at it, not being able to find out where it's going wrong.
What I would do:
Enhanced e-commerce: replace your code which is for the old e-commerce with this code which is for enhanced e-commerce. Reason: new (enhanced) is backward compatible with the old and has lots more features, so 0 point of using old e-commerce. Reason 2: the enhanced e-commerce implementation seems "cleaner" in the sense that all the data is sent with 1 single hit at the end (->sendEvent();), whereas the old e-commerce first sends the transaction (->sendTransaction();) then later the products with separate hits (->sendItem();).
Debug: enable debug mode to find out if/why your hits are being rejected by the API.
With enhanced e-commerce it should be something like:
$analytics->setDebug(true)
->setEventCategory('Checkout')
->setEventAction('Purchase')
->sendEvent();
$debugResponse = $response->getDebugResponse();
print_r($debugResponse);
And you should get debug from the API that will look like this:
{
"hitParsingResult": [
{
"valid": false,
"hit": "GET /debug/collect?tid=fake\u0026v=1 HTTP/1.1",
"parserMessage": [
{
"messageType": "ERROR",
"description": "The value provided for parameter 'tid' is invalid. Please see ... for details.",
"parameter": "tid"
},
Filters: if your hits are not rejected by the API (once they are validated you have to remove the debug for them to be actually sent), I would look in GA to check if you don't have filters excluding your hits.
Quotas: although unlikely, I would also check if you haven't reached the API limits hence why your data isn't being collected.
BONUS: User-ID: if people making purchases have created a user account on your website, use your database ID as User ID: it will be easier to implement (you don't have to reverse engineer the Client ID, use your database ID), and will track the same user regardless of the browser/device used (Client ID is linked to the Cookie, so will be different for each device/browser the user uses, your database ID will always be the same as long as people log in with the same account)
I've tried the enhanced e-commerce again. I've done that before as well, but this time with the debug function on. The client ID gets send properly as seen in hitPersingResult[0]['hit']. But still nothing appears in google Analytics.
Also we're not hitting the limits. I've literally copy pasted the example and this is my response:
Array
(
[hitParsingResult] => Array
(
[0] => Array
(
[valid] => 1
[parserMessage] => Array
(
)
[hit] => /debug/collect?v=1&tid=UA-xxxxxxxx-11&cid=161460xxxx.xxxx180000&uid=161460xxxx.xxxx180000&ti=1802.48511-1518713633&ta=test%20affiliation&tr=206.95&tt=3.4623966942149&ts=0&pa=purchase&ec=Checkout&ea=Purchase&t=event&pr1id=2033&pr1nm=xxxxx&pr1br=brand&pr1ca=xxxxxx&pr1pr=xxx&pr1qt=1
)
)
[parserMessage] => Array
(
[0] => Array
(
[messageType] => INFO
[description] => Found 1 hit in the request.
)
)
)
Related
I had made a simple APP which automatically creates my upwork invoices to my Invoice ninja setup but lately, upwork side broke. I saw that there were updates and changes on it but after my research, nothing changed in my specific call. After the authorization, I am using the following call:
$finreports = new \Upwork\API\Routers\Reports\Finance\Accounts($upwork_client);
$freelancerReference = "8009XXX";
$params = array(
"tq" => "SELECT amount, notes WHERE date >= '2018-06-01' AND date <= '2018-06-30'"
);
$results = $finreports->getOwned($freelancerReference, $params);
echo "<pre>".print_r($results, true)."</pre>";
and i am receiving this:
stdClass Object
(
[version] => 0.6
[status] => error
[errors] => Array
(
[0] => stdClass Object
(
[reason] => invalid_query
[message] => Internal Server Error
)
)
The auth seems OK because I can successfully get the response from:
$auth->getUserInfo();
it's a pity to hear that your reporting system stopped working correctly. Unfortunately, you use the API which is marked for deprecation. Inherently, the changes are being rolled out, and that seems to be the root of the issue you experience - see the proper announce.
Since mnovozhilov is the author on the Upwork API library files that I've read, it is great to have his confimation that the Accounts API has been deprecated.
Perhaps you can get the information you need through billings. Just a note that the API documentation says to use:
from upwork.routers.reports import billings
But for the version I have, there is an extra finance folder, so I need to use:
from upwork.routers.reports.finance import billings
I've been checking my paths by looking in File Explorer at the install folder\Lib\site-packages\upwork...., to see where the import files are located.
With your team reference you can use get_by_buyers_team(self, buyer_team_reference, params)
With your company reference you can use get_by_buyers_company(self, buyer_company_reference, params)
Quetion:
How would I cancel a pre-approved payment using PayPal's API operations? I have the Pre-approval key of the payment to be cancelled but I can't find a way to do it.
I did some digging over the internet and found this CancelPreapproval API Operation but that document is not very helping for a starter like me. Few things are missing like what would be the link where I'd send the cancel request? Can't find any example. Need help.
I did tried cancelling the payment by using this code but it fails.
$security_user_id = $neworder->security_user_id;
$security_password = $neworder->security_password;
$security_signature = $neworder->security_signature;
$security_application_id = $neworder->security_application_id;
$headers_array = array("X-PAYPAL-SECURITY-USERID" => $security_user_id,
"X-PAYPAL-SECURITY-PASSWORD" => $security_password,
"X-PAYPAL-SECURITY-SIGNATURE" => $security_signature,
"X-PAYPAL-APPLICATION-ID" => $security_application_id,
"X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
);
$pay_result = wp_remote_request('https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval', array('method' => 'POST', 'timeout' => 20, 'headers' => $headers_array, 'body' => $maincode));
This PayPal PHP SDK will make it very quick and easy for you. Just extract it into your project structure as you would any other class, and make sure to setup the config file correctly with your own sandbox and/or live PayPal credentials.
Then you can look in the /templates and you'll see a CancelPreapproval.php setup and ready to go. It'll be fully functional. All you'll have to do is plug in your preapproval key and it'll handle the rest for you successfully.
There are lots of /samples and there is a file in /templates for pretty much every API call PayPal has.
You can get this done within minutes using that class. Let me know if you have any specific questions about it.
I created a tool for our support team that gets all private messages from our +/- 70 Facebook fan pages for easy processing and not having to manually click through all the pages to check if there are new or unanswered messages.
This tool worked perfectly for a couple of months but recently we've been getting the following error when trying to send a reply on a private message:
[error] => Array
(
[message] => (#504) Invalid reply thread id
[type] => OAuthException
[code] => 504
)
My code is as follows:
$fb->setAccessToken('%access_token%');
$edge = 't_id.' . $thread['id'] . '/messages';
$result = $fb->api($edge, 'POST', array('message' => $message));
I use extended access tokens but just to be sure I renewed them all. The value in $thread['id'] is the value from 'thread_id' from querying FQL 'message' table.
I searched in the Facebook docs but it looks like they removed everything concerning this subject, which could imply they removed the functionality entirely.
They say something about a new messages system which they are rolling out on the thread reference page, but I can't find anything else about this subject. https://developers.facebook.com/docs/reference/api/thread/
EDIT:
As you can see in the comments the documentation can be found here: https://developers.facebook.com/docs/graph-api/reference/page/conversations
I just made a new page for testing and I can't seem to get a valid access token in the graph api exlorer for accessing the edge /{page-id}/conversations. I remember this has happened before when I was developing my tool. The same access tokens didn't work for a week and then suddenly started working again...
I have successfully done with the authentication of Evernote with PHP.
And I have got this response.
Array ( [oauth_token] => S=s1:U=6316e:E=144fcfdfdb9:C=13da54cd1ba:P=185:A=maheshchari-2599:V=2:H=6da806fe92b9289cf0334f04e2afdc55 [oauth_token_secret] => [edam_shard] => s1 [edam_userId] => 405870 [edam_expires] => 1395813907897 [edam_noteStoreUrl] => https://sandbox.evernote.com/shard/s1/notestore [edam_webApiUrlPrefix] => https://sandbox.evernote.com/shard/s1/ )
Now, I want the list of notebooks of the user which has been authenticated with evernote.
I have done a lot of research online but I couldnt find any thing which helps, I have came to know that guid is necessary to get the list of notebooks.
From where I can find that? And how can i access the notestore and userstore?
How can i call the functions of notestore and userstore to fetch the data of user's account and user's notes in php?
Thanks in Advance.
Using the Evernote SDK for PHP, you can list notebooks like the way below:
$client = new Client(array('token' => $authToken));
$noteStore = $client->getNoteStore();
$notebooks = $noteStore->listNotebooks();
All the API references can be found here.
Also, you shouldn't make your token public. Please make sure your token string you put can't be used any more. If you need more help on this, you can get supports from Evernote developer support.
https://github.com/evernote/evernote-sdk-php
go to this link and download this zip then go to sample folder then go to client folder and run EDAMTest.php page.
and add authtoken.
I am trying to write a PHP script that will allow me to do two things:
Allow users to use their Hotmail (I think its called 'Live' now?) account to authenticate themselves to a website
Retrieve an authenticated users contact list from Hotmail.
I have trawled the internet for the past 6 hours, looking for at least a working example that I can modify/extend to do the above two things. There are several dozens similar questions asked here on SO for example - NONE of the proffered answers work any more (admittedly, some of the questions were a few years old).
I tried the Microsoft site and downloaded the latest version of their API which seems to evolve at a rather alarming rate. I finally managed to track down an API which has not been deprecated (yet?).
I followed the instructions and when I attempted to authenticate, I was rewarded with the following mesage, for my efforts:
We're unable to complete your request
Windows Live ID is experiencing technical difficulties. Please try again later.
I immediately tried the online version of the demo and perhaps unsurprisingly, that worked like a charm.
As an aside, I managed to implement the same functionality for Yahoo and GMail, using their OPEN APIs, under an hour each. Now, it is possible that my unmitigated hatred of all things proprietary (sorry make that Microsoft), is causing me to lose the plot a little here.
Has anyone ACTUALLY (in 2012) managed to get a working sample in PHP that allows:
Hotmail (live?) user authentication
Hotmail user contact email retrieval
If you have, a code snippet, or a link to where I can find such a snippet would be very useful, as I have so far, wasted a whole afternoon trying to work the Microsoft Live API via PHP.
PS: No, I'm not interested in OpenInviter, its broken.
i wrote my own oauth library based around a single array for each service provider. this array contains all of the data required to perform authentication and retrieve user data. the array i use for msdn (ie. hotmail, outlook, xbox, msn) is:
$msdn = array
(
'oauth_version' => '2',
'oauth_method' => 'GET',
'redirect_user_params' => array
(
'url' => 'https://oauth.live.com/authorize',
'response_type' => 'code',
'http_params' => array
(
'url',
'client_id',
'redirect_uri',
'response_type',
'scope',
'state'
)
),
'obtain_access_token_params' => array
(
'url' => 'https://oauth.live.com/token',
'grant_type' => 'authorization_code',
'http_params' => array
(
'url',
'client_id',
'client_secret',
'code',
'grant_type',
'redirect_uri',
'scope'
)
),
'scope' => 'wl.signin wl.basic',
'obtain_user_data_params' => array
(
'url' => 'https://apis.live.net/v5.0/me',
'http_params' => array
(
'url',
'access_token',
'scope'
)
),
'client_id' => 'xxxxx', // = oauth_consumer_key in oauth 1.0 lingo
'client_secret' => 'xxxxxxxxxxxxxxx',
'readme_url' => 'http://msdn.microsoft.com/en-us/library/live/hh243647.aspx'
);
the parameters for each of the three oauth stages (ie "redirect user", "obtain access token" and "obtain user data") are in the http_params arrays. in the case of msdn these parameters end up in the query query string of the url that i send out with curl (since msdn only accepts GET, not POST).
i haven't tried retrieving the user's contact address book, but this would just be a case of extending the scope element with whatever extra information you require (documented here http://msdn.microsoft.com/en-us/library/live/hh243646.aspx). as you can see from the http_params arrays, the scope parameter is used in each of the three oauth stages.
Try out a Hotmail/MSN/Live import on the CloudSponge test drive to see if that's the user experience you're hoping for.
If it works for you, you can use our widget or our API. If you want to use the API, we have a PHP wrapper already written for your convenience.
Please confirm your callback url is with http:// if you only put www.domain.com then get this issue..