I have enabled billing and have 10$ balance in my project,
I have created Key for browser applications, with right referrer
I have generate key , my code is given below
$api_key = 'My Key is Here';
$response = file_get_contents('https://www.googleapis.com/language/translate/v2?key='.$api_key.'&q=hello%20world&source=en&target=de');
//decode json to array
$json = json_decode($response);
//show the json array in a readable format
echo '<pre>';
//show array
print_r($json);
I am getting following errors
stdClass Object
(
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => usageLimits
[reason] => accessNotConfigured
[message] => Access Not Configured. Please use Google Developers Console to activate the API for your project.
)
)
[code] => 403
[message] => Access Not Configured. Please use Google Developers Console to activate the API for your project.
)
)
Please would you help me to figure out, what i have missed or did wrong that i get above error.
Many Thanks
Make sure you have enabled translate API in developer console.
Related
I want to get my PayPal accounts transaction history. Just the same data I can export when I'm logged in.
All the transactions there where not generated via REST API itself.
I read some posts where it says that one can't use, for example, "Transaction Search" API (https://developer.paypal.com/docs/api/transaction-search/v1/) in this case.
I tried this out but could not get it to work.
After I got my access_token:
stdClass Object
(
[scope] => https://api.paypal.com/v1/payments/.* openid https://api.paypal.com/v1/vault/credit-card/.* https://uri.paypal.com/services/subscriptions https://uri.paypal.com/services/identity/activities https://api.paypal.com/v1/vault/credit-card
[access_token] => xxx
[token_type] => Bearer
[app_id] => xxx
[expires_in] => 32400
[nonce] => 2020-09-05T22:25:09ZHAnra0QUpsxgo4E90gqEKtgtUNgkGNzVs1IVCBJfiu0
)
I tried to call the /v1/reporting/transactions API an got back:
stdClass Object
(
[localizedMessage] => No permission for the requested operation.
[suppressed] => Array
(
)
[name] => PERMISSION_DENIED
[message] => No permission for the requested operation.
[details] => Array
(
[0] => stdClass Object
(
[field] =>
[value] =>
[location] =>
[issue] => No permission for the requested operation.
)
)
[information_link] => https://developer.paypal.com/docs/classic/products/permissions/
[debug_id] => feb53d91bc653
)
The "information_link" in the response ends up at 404.
And yes, I activated "Transaction Search API" in my Developer Account.
Then I found this old API:
https://developer.paypal.com/docs/archive/express-checkout/ht-searchRetrieveTransactionData-curl-etc/#
There, PayPal says that this API is deprecated but will still work ... for customers who are using it.
For me, this also does not work, response:
{
"name": "INTERNAL_SERVICE_ERROR",
"message": "An internal service error has occurred",
"debugId": "a2b554e8cc7b",
"links": [
{
"href": "https://developer.paypal.com/docs/api/overview/#error",
"rel": "information_link"
}
]
}
So how to get existing PayPal transactions of my PayPal account via API? There must be a way, there are many tools who import this data, but which API do they use?
I tried this out, it don't worked, I could not get the data.
And yes, I activated "Transaction Search API" in my Developer Account.
After activating it you need to wait 9 hours, and ensure you get a new access_token that is not the same as your old one. You should then have a new [scope] returned which includes https://uri.paypal.com/services/reporting/search/read
Without that scope returned, you can't use the Transaction Search API.
There must be a way, there are many tools who import this data, but which API do they use?
The Transaction Search API is actually not very useful -- most people use the Reports tab in www.paypal.com and download a CSV file
I am using the [Google Analytics API PHP] by wanze. I was able to set up authentication (using web auth only) and everything and I stored the token in a session. On another page, I use this code to find all the accounts the user logged in with.
session_start();
include('GoogleAnalyticsAPI.class.php');
$ga = new GoogleAnalyticsAPI();
$ga->auth->setClientId('replaces'); // From the APIs console
$ga->auth->setClientSecret('replaces'); // From the APIs console
$ga->auth->setRedirectUri('replaced'); // Url to your app, must match one in the APIs console
// Get the Auth-Url
$url = $ga->auth->buildAuthUrl();
// Set the accessToken and Account-Id
$ga->setAccessToken($_SESSION['accessToken']);
$ga->setAccountId('ga:xxxxxxx');
// Load profiles
$profiles = $ga->getProfiles();
print_r($profiles);
$accounts = array();
foreach ($profiles['items'] as $item) {
$id = "ga:{$item['id']}";
$name = $item['name'];
$accounts[$id] = $name;
}
// Print out the Accounts with Id => Name. Save the Id (array-key) of the account you want to query data.
// See next chapter how to set the account-id.
print_r($accounts);
I this returned:
Array
(
[http_code] => 403
[error] => Array
(
[errors] => Array
(
[0] => Array
(
[domain] => usageLimits
[reason] => accessNotConfigured
[message] => Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
[extendedHelp] => https://console.developers.google.com
)
)
[code] => 403
[message] => Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
)
)
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/home3/chalzzy/public_html/dashboard/dashboard.php</b> on line <b>21</b><br />
Array
(
)
I see in a lot of places that I need to remove or set all refers in a "Referrals" section in the console but I can't seem to fins that in the new or old console. If it is there and I can't find it, can you please give me a url or a screenshot?
Also, these are all the APIs I have installed for this project:
Thanks in advance,
Ben
Also, let me know if you need more details!
Hey (I'm sorry it was a very stupid question),
What you have to do is add to your APIs list "Analytics API" in the Developers Console.
I've got a REST call to my Google calendar that works out fine on my old website (www.gmbc.org/events.php), but when the identical call is made from a codeigniter controller, the timeMin / timeMax options cause it to throw a 400 at me (remove them, and the call successfully retrieves the whole calendar from 2012):
$st_date = date(DateTime::ATOM);
$end_date = date(DateTime::ATOM, time()+(31 * 24 * 60 * 60));
$call_url = 'https://www.googleapis.com/calendar/v3/calendars/calendar%40gmbc.org/events?timeMin='.$st_date.'&timeMax='.$end_date.'&singleEvents=true&orderBy=startTime&key=[mykeythatworksjustfine]';
$events_call = $this->curl_get($call_url);
echoing $call_url confirms it's being created identically, and print_r-ing the result confirms it's reaching google:
stdClass Object (
[error] => stdClass Object (
[errors] => Array (
[0] => stdClass Object (
[domain] => global [reason] => badRequest [message] => Bad Request )
)
[code] => 400 [message] => Bad Request
)
)
...what could possibly be going on? Does codeigniter interfere with the curl call?
I am able to successfully retrieve events from this calendar with TimeMin and TimeMax set using the API explorer: https://developers.google.com/apis-explorer/#p/calendar/v3/calendar.events.list?calendarId=calendar%2540gmbc.org&timeMax=2014-11-30T00%253A00%253A00Z&timeMin=2014-10-01T00%253A00%253A00Z&_h=2&
The query it's sending is:
GET https://www.googleapis.com/calendar/v3/calendars/calendar%40gmbc.org/events?timeMax=2014-11-30T00%3A00%3A00Z&timeMin=2014-10-01T00%3A00%3A00Z&key={YOUR_API_KEY}
Try making sure the query you are sending from PHP ends up the same.
How can I retrieve a specific post/discussion from a open group through LinkedIn API using PHP.
I was trying with the following API request as shown in here http://developer.linkedin.com/documents/groups-api#post :
https://api.linkedin.com/v1/posts/5835685921059532803:(id,type,category,creator,title,summary,creation-timestamp,relation-to-viewer:(is-following,is-liked,available-actions),likes,comments,attachment,site-group-post-url)
But this returns the following error:
Array
(
[status_code] => 400
[data] => stdClass Object
(
[errorCode] => 0
[message] => Invalid Post.id String {5835685921059532803}
[requestId] => XW2XMPBNKY
[status] => 400
[timestamp] => 1391441328953
)
)
Now, what's the error I have made with this request? What should I do to get a specific discussion?
Thanks.
I just solved the problem. The problem was while making the request. The discussion id (5835685921059532803) I was sending with URL was in wrong format. It should be like: g-GROUP_ID-S-DISCUSSION/POST_ID, for example: g-24405-S-5835685921059532803.
So the URL should be:
https://api.linkedin.com/v1/posts/g-24405-S-5835685921059532803:(id,type,category,creator,title,summary,creation-timestamp,relation-to-viewer:(is-following,is-liked,available-actions),likes,comments,attachment,site-group-post-url)
Hope this would save someone's valuable time.
You need An Api key and Secret key,to get an AUTHORIZATION_CODE,using that AUTHORIZATION_CODE,you will get an Access Token,and with that Access Token if you hit the url,then you will get the proper data,
details http://developer.linkedin.com/documents/authentication
I'm using Abraham's twitteroauth class and after authenticating a user I'm trying to grab a list of ids the user is following.
Authentication works fine because I can run:
$user = $connection->get('account/verify_credentials');
And get the required result. So according to the test.php file on Github's twitteroauth I should also be able to run the following:
$friends = $connection->get('statuses/friends');
But if I var_dump the output I get the following:
stdClass Object( [errors] => Array ( [0] => stdClass Object ( [message] => Sorry, that page does not exist [code] => 34 ) ))
The "statuses/friends" seems to be the wrong request, so could anyone point me in the right direction?
Should have read a bit further. The answer is to go for:
$friends = $connection->get('friends/ids');