https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=20.9533951,75.9364752&radius=500&types=food&key=put_your_key_here
This is the URL of google maps api. Which returns json data if we pass the key at the last. and hit that url from our browser directly.
So is there anything like that in twitter as well? By which we can pass our consumer key or something like that at the end of link like this https://api.twitter.com/1.1/trends/available.json
Because without any tokens if we hit this URL then its giving error : Bad Authentication data Code : 215
Please help me. i am finding this from very long and have no luck.
Please Thank You So Much.
The short answer is no.
The long answer is that all requests to the Twitter REST API need to be authenticated using OAUTH. You need to follow the OAUTH process and use the tokens as described starting here.
&oauth_consumer_key= your consumer key
&oauth_nonce=nonce
&oauth_signature_method=HMACSHA1
&oauth_timestamp=1505894968
&oauth_token=token
&oauth_version=1.0
&oauth_signature=signature
You have to send these header with your request then it will work fine
Related
I'm trying to use the Twitter API in Google Script to get the non-public metrics of my posts.
I believe have done all of the authentication properly since I am able to get the information when using Postman. I have generate a consumer_key, a consumer_secret, an access_token, and a token_secret.
According to the twitter documentation , I MUST use Oauth1.0 (https://developer.twitter.com/en/docs/twitter-api/metrics).
In order use the Oauth1, I used Google's own script for Twitter Oauth1 (https://developers.google.com/google-ads/scripts/docs/examples/twitter-oauth10).
I was able to take that code (along with the library it required) and successfully retrieve the tweets for my username.
My attempt to get the non_public metric was replacing the "https://api.twitter.com/1.1/statuses/user_timeline.json" with the GET request I had from POSTMAN but it returned a "401 error".
I have a hunch that I can't just replace that url with my own but I am unsure how to approach it.
In summary:
Tokens/Twitter Authorization/GET request are written properly since they work in Postman
Google Script is writing properly since the default URL works
Unsure how to replace the default url to accomplish different tasks
Ended up figuring it it out!
I was not supposed to pass the entire url as a replacement for "https://api.twitter.com/1.1/statuses/user_timeline.json".
It is supposed to be replaced by the "base" url. In my case this was "https://api.twitter.com/2/tweets".
I then had to change the variable "params" that feed into it.
note that the params is from the code provided by Google in my original post
They have to be in the following format (https://developer.twitter.com/en/docs/tutorials/twitter-api-google-sheets):
params = {
"tweet.fields": "author_id,created_at,lang",
"ids": "21,1293593516040269825,1334542969530183683",
}
I was able to add my own fields such as "non_public_metrics,organic_metrics" to get:
params = {
"tweet.fields": "author_id,created_at,lang,non_public_metrics,organic_metrics",
"ids": "21,1293593516040269825,1334542969530183683",
}
I hope this helps someone someday :)
Best solver or fellow problemized,
The context:
The reason I’m asking this question is that I am trying to learn how to automate clinking links in emails with python3. I’ve gone in depth on how to achieve this with selenium but without success. I’ve just heard that this could be possible with API.
I've been trying to find a documentation or explanation for the past 2 hours on how to use something like AHEM - Ad-Hoc Temporary Email Server’s API. https://www.ahem.email/help/api
An hour ago I didn’t know anything and now I know how to call json API with requests and an authentication key. yay me...
The problem:
Now I need to get an authentication token but it asks for content type string and a request body. I’m lost. I’ve used google and youtube but I can only find gmail, reddit and hackernews API documentations which are not much alike I think.
I'm sorry for the vague description of the problem that, quite honestly, resembles my knowledge about the subject. More clarity could be achieved by following the link and taking a look at General: General APIs > POST > Get access token.
The solution?
Does anyone know a good book, video or just plain advice?
Thank you so much in advance!
I hope the answer is not on the front page of Google if you get what I mean.
This should do the job.
import requests
base = 'https://www.ahem.email'
url = f'{base}/api/auth/token'
respone = requests.post(url=url)
if respone.status_code == 200:
token = respone.json()['token']
bearer = f'Bearer {token}'
header = {'Authorization': bearer }
url = f'{base}/api/alive'
print(requests.get(url=url, headers=header).json())
I try to fetch all product data list in json from WooCommerce API and type address bar http://www.batata.in/wc-api/v3/orders. But it give an error:
{"errors"[{"code":"woocommerce_api_authentication_error","message":"oauth_consumer_key parameter is missing"}]}
I tried all things but issue is not fixed. Rest API is on.
If anybody know any other way to find product list in json format from WooCommerce WordPress plugins, then please tell me.
I have faced the same problem. After some research, I have solved this issue. Kindly check that your site secure or not [http or https]. I missed the "s" for http.
Please note that you need to provide consumer key, nonce, signature with your rest api call. Following is the format which worked for me.
http://SomeURL.com/wc-api/v2/orders?oauth_consumer_key=########&oauth_timestamp=######&oauth_nonce=#############&oauth_signature_method=HMAC-SHA256&oauth_signature=##########################
For generating nonce and signature I recommend you use some wrapper available for your platform. I used php so got a nice library here.
https://github.com/woocommerce/wc-api-php
Important:- Even after following all above steps correct I got the same issue you faced. It kept giving me error "oauth_consumer_key parameter is missing" which actually was misleading. The issue I figured out was the basic http auth. I had http authentication in place so the curl request I used to fire was returning 401 unauthorized. If you are using php you will understand following line.
curl_setopt($this->ch, CURLOPT_USERPWD, "USERNAME:PASSWORD");
And it worked. So point here is you can try this or play around with your curl/socket or any client you are building and don't focus on the error message as it is misleading most of the time.
Sandipa Mukherjee's answer is right.
For http:// additional oauth parameters are required, because it's not safe.
My suggestion is to use the https:// server for wordpress.
Please refer to https://scriptstown.com/how-to-setup-cloudflare-ssl-and-configure-origin-certificate-for-apache/
I am trying to use the plivo.com api with Filemaker to send SMS with my database.
I am using "insert from URL" to POST to the api, like below:
(ACCOUNTID, FROMNUMBER, and TONUMBER has been switched out)
httpspost://api.plivo.com/v1/Account/ACCOUNTID/Message/{"src":"FROMNUMBER", "dst":"TONUMBER", "text":"Testing text"}
The plivo site said something about using JSON for receiving, I had tested with other Filemaker solutions (FmSms) and confirm the functionality is working, so it has to be my post query is in the wrong format.
Would be great if someone of experience can give me some pointer in solving this issue.
Linkage to Plivo's documentation regarding messaging
Thanks in advance
Sunny
This will not work with FileMaker alone. The webservice accepts content-type application/json, FileMaker can send x-www-form-urlencoded only.
It may be possible to use a web viewer with some javascript to handle the request and return data back to FileMaker. See the blog post here: http://www.soliantconsulting.com/blog/2014/11/filemaker-and-javascript-ajax-post
Also, the free base elements plugin will allow you to set custom headers and should also work.
We have an assignment to check the compatibility of Quick connect project for Foursquare against the REST/JSON 1.1.
When I am testing the process, while invoking Rest API for query Check-in, the process is throwing an error – “OAuth token invalid or revoked”. Can you kindly help to fix this issue.
Access_token for this was generated by registering a sample app with Foursuare.com, having www.google.com as welcome page and redirect URL. Please let me know if this is causing the issue.
Also, let me know is there is any standard method to generate the access_token for this.
Thanks in advance.
Regards,
Shree.
It sounds like you're not following Foursquare's instructions on connecting properly, or need to reconnect to get a new access_token. Keep in mind that the access_token isn't the code that comes back in the redirect, the code needs to be used to exchange for the access_token.