I wanted to create a web service like feature that would provide me the JSON response from the google analytics, i plan to do some processing on the GA data and then output the response to the user who would have requested for my service.
I selected PHP as my language and used google-api-php-client from google and now since i don't want to authorize every time to get Token, i thought of using Service account with which i would directly use keys.
I downloaded the sample code from Google changed client ID and Service Account Name and Key location.
But then this Error Came
Catchable fatal error: Argument 3 passed to Google_HostedmodelsServiceResource::predict()
must be an instance of Google_Input, none given, called in /var/www/webservice/GA/serviceanalytics.php
on line 62 and defined in /var/www/webservice/GA/google-api-php-client/src/contrib/Google_PredictionService.php on line 36
I found that the second argument that example is passing should have been the third argument.
So what should be the second argument. A little insight or a working code will be appreciated :)
Thanks
The link you have posted svn/trunk/examples/prediction/serviceAccount.php
Is for use with Google Preditions api If you have supplied a client ID and Service Account Name and Key location for an api that was set up to allow google analytics this wont work. I sugest you look for an example using Google Analtyics or change the apis console to allow preditions api while you are getting to know the sample code for Google Preditions.
Related
I am using instaFlights Search API of Sabre. I am unable to get response for any of the IATA 3-letter codes other then "JFK" and "LAX". Whenever I pass any other IATA code in the request like "DXB", i recieve an error.
please note that I am working on test environment and testing the api on the link given below.
link of API test page
The error that i receive every time i request with any other IATA Code.
Are you in CERT or PROD?
If you are still in CERT, only a subset of available flight schedules/fares will be found and returned. Do you have access to PROD? If you're working in PROD and not getting any results then I would think something else is malformed in your request.
InstaFlight is limited to specific POS (Point of Sale) and the available city pairs are tied to the POS being used.
I recommed you to contact the API Support team for further details.
I have a web app written in PHP that uses Mailchimp API v3. It was working ok until two days ago. I can't figure out what is going on. When I try to create new interest, I get 500 error, so in my response I don't get interest ID which I use later on. However, the interest gets created, which is weird.
I use the correct ENDPOINT. It's the same one shown in the API Playground. Even when I try to do this in the PLAYGROUND, I get the same error, but the interest (group) gets created.
Endopoint:
"http://".$dc.".api.mailchimp.com/3.0/lists/".$list_id."/interest-categories/".$subgroup_id."/interests"
I'm trying to integrate a web app in PHP to integrate Xero. My objective is to submit a leave form to Xero from the application.
I'm using https://github.com/XeroAPI/XeroOAuth-PHP and did manage to get the employee lists. But the example request shows I need to pass the LeaveTypeID along with the EmployeeID. Where can I get the LeaveTypeIDs ie. What is the Leave type ID for Annual Leave or Sick leave. Here is the Sample xml Request I found in the example in http://developer.xero.com/documentation/payroll-api/leaveapplications/
<LeaveApplications>
<LeaveApplication>
<EmployeeID>5abad362-28aa-4c2c-a9cb-0899f7262d62</EmployeeID>
<LeaveTypeID>dc182d9a-a270-4f4e-acd7-af702d5a4382</LeaveTypeID>
<Title>My Test Leave</Title>
<StartDate>2013-04-11</StartDate>
<EndDate>2013-04-11</EndDate>
</LeaveApplication>
</LeaveApplications>
I searched the Internet, Xero documentation and the community portal but nothing is there> Any help is much appreciated.
Updates:
#ronanq - I've Tried that, using the following code to get the LeaveTypes from the Demo account
$response = $XeroOAuth->request('GET', $XeroOAuth->url('PayItems', 'payroll'));
pr($response); exit;
getting the following response:
code => 401
response => You do not have permission to access this resource.
The other end points are working fine.
Solution:
Thanks to #ronanq. the "payroll.payitems" needed to be added as a scope on Authorization. That will give access to get the LeaveTypes from xero
You can retrieve leave types and their associated LeaveTypeIDs from the PayItems endpoint.
I want to be able to query the Gmail API through a HTTP GET request.
I'm trying to query the Gmail API to get a message unread count from my INBOX label.
API Reference : https://developers.google.com/gmail/api/v1/reference/users/labels/get
The API reference shows the following HTTP request to get the unread count.
GET https://www.googleapis.com/gmail/v1/users/userId/labels/id
The API reference also says you need authorization through OAuth 2.0.
I managed to get examples working in the PHP library to successfully query the API but there is not enough PHP documentation to write any specific code.
However the API reference lists all HTTP calls to access different parts of the API however I can't figure out how to use OAuth (Access Tokens) with these HTTP requests?
The official PHP client library comes with a few examples like this one that shows you how to authenticate using OAuth. The API documentation also has a lot of information about this process.
To get the unread messages count, you should do something like this:
// $googleClient is an authenticated instance of 'Google_Client'
$gmail = new \Google_Service_Gmail($googleClient);
$label = $gmail->users_labels->get('me', 'INBOX');
$unreadCount = $label->messagesUnread;
You might have to turn 'Conversation view' off in the Gmail settings for this to return an accurate result.
Accessing the Gmail API in php should be similar to other Google APIs from php. Maybe look at quickstart examples from the calendar or Google Drive APIs in PHP and work from there?
If you have the oauth2 access token you can often just put it in the "Authorization" header. c.f. https://www.rfc-editor.org/rfc/rfc6750#section-2.1
Though honestly, I think it'll be a lot easier long-term to figure out how to do it with the PHP Google APIs library...
I'm using the Salesforce REST API and found it very hard to find decent documentation.
I can successfully log in with OAuth and i can push new accounts to Salesforce.
I use the instance url to make the API calls and i send the following fields to create an account object:
Name
Rating
Description
The problem is that I created a free trial (which sits on na9.salesforce.com) and everything worked fine.
I created a second free trial to check if everything works with another account, but the rating field is not available... I get the following message from Salesforce:
"[{"message":"No such column 'rating' on sobject of Account"}]"
Why is that?
Also, is it possible to add notes to a created account using POST? And is it possible to create Leads instead of Accounts using the API?
Thanks in advance,
A feature called field level security (FLS) can mean that even standard fields are not accessible, check the FLS settings on account in your second org.
Docs for the REST API are on the developer force site