I am trying to get the tweets associated with this user #WeAreShootProd but the JSON and XML is empty.
https://api.twitter.com/1/users/show.xml?screen_name=WeAreShootProd
https://search.twitter.com/search.json?rpp=10&callback=?&q=from:WeAreShootProd
As you can see from this link there are at least 5 tweets
https://twitter.com/WeAreShootProd
Does anyone know why they aren't appearing in the XML or JSON?
Thanks very much
When I tried the URL you provided, I see the following response:
{
errors: [
{
message: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.",
code: 68
}
]
}
I suspect the problem was that in the JSON call, you had two question marks in the query portion of the URI. But whatever the problem was at the time, the issue is rather moot. That version of the Twitter API is no longer supported.
Related
I've stumbled upon a problem whilst working on a weather app. I have 401 error popping up every time i'm trying to fetch API from openweathermap.com. I've tried everything so far to fix this problem like waiting some days until my API key would work for me. I also tried to create a new API key and use it but failed at it again. Finally i tried to create another account on openweathermap.com but still have this error. Can anyone help me to find out what is the problem?
P.S. i used a valid API for checking a basic weather info that is available for free subscribtion.
401 Error screenshot
Your API Key is provided as a value to query parameter: appid is wrapped in {}. Remove those braces and perform the request again.
Very often, you will find the usage of {} in the documents, they represent placeholders in a string and are not meant to be part of the final string.
Weathermap Docs: How to make an API Call?
Also, please, make sure that you DO NOT share any essential API Keys in a public forum.
{} should be removed inside the url. It should be
let api = `https://api/openweathermap.org/data/2.5/weather?q=${city}&appid=e2850163218373000f889c28107ac0cf`
I am working on a Covid-19 Tracker Project which requires me to get and use api data through the URL https://thevirustracker.com/free-api?global=stats recommended on the website https://thevirustracker.com/api but for some reason I can neither access the suggested website nor can I get the required data through the suggested URL.
Instead I'm trying to do it through https://corona.lmao.ninja/v2/all?yesterday but the result has a slightly different structure and therefore I'm finding it hard to code in line 48 of my GlobalData.js file on Visual Studio in order to display the "cases" figure of the result of the api GET request under the "Global Data as of Today" in the first Paper section of the app.
Can someone please help me out?
Pic Result of api GET request
Pic GlobalData.js
Fetch api sends always you a promise so in console you can see that is a promise.
try this you will get your actual data in console.
fetch('https://corona.lmao.ninja/v2/all?yesterday')
.then((res)=>res.json())
.then((data)=>console.log(data))
.catch((err)=>console.log(err))
I recently got the idea to scrape information from instagram accounts and their posts, like the amount of comments or amount of likes. I got so far that I figured out while debugging in chrome that for example the link https://www.instagram.com/instagram/?__a under the network tab returns a JSON with the wanted information, but what is actually loaded is still the normal website html code.
so far I tried in python with this code:
import urllib.request
r = urllib.request.urlopen(url)
print(r.read())
or in javascript :
window.onload = function () {
res = fetch("https://www.instagram.com/instagram/?__a", {
method: 'get'
}).then(function (data) {
return data.json();
}).catch(function (error) {
console.log("ERROR".concat(error.toString()));
});
console.log(res.user);
};
So the problem I have, is that when using these functions I only get the website code (html), is there a way to only get the JSON which is loaded in the background? I know people will recommend me using the instagram api, but I have no website nor a company to register.
I ran into a problem trying to get the API to do what I wanted, and really just needed JSON data including urls and captions for images for a specific account.
Use the following GET request:
https://www.instagram.com/account_name/?__a=1
where account_name is the profile I'm scraping.
It returns all JSON I needed for my task.
Update 2022:
You can no longer get the JSON output by adding the query string ?__a=1.
Currently, it would help if you used the following query string to get profile information, video, and post information on Instagram:
https://www.instagram.com/instagram/?__a=1&__d=dis
Trying to get the Json loaded in the background is too much work for a simple problem.
You should use the Instagram Api. Just put your name as a company.
At the recent Google IO conference new Gmail APIs were announced. Client libraries are missing examples and documentation which is understandable given the short time that has gone by.
UPDATE: It wasn't clear in the original question - I've already tried encoding the whole message as Base64 string.
I'm trying to create a new draft message:
var request = gapi.client.gmail.users.drafts.create({
'message' : {
'raw' : Base64.encode("To: someguy#example.com\r\nFrom: myself#example.com\r\nSubject: my subject\r\n\r\nBody goes here")
// 'raw' : "VG86IHNvbWVndXlAZXhhbXBsZS5jb20KRnJvbTogbXlzZWxmQGV4YW1wbGUuY29tClN1YmplY3Q6IG15IHN1YmplY3QKCkJvZHkgZ29lcyBoZXJl"
// 'raw' : "From: me#example.com\nTo:you#example.com\nSubject:Ignore\n\nTest message\n"
}
});
request.execute(function(response) {
});
Can you please provide me with the correct syntax to do that?
(Base64.encode is coming from http://www.webtoolkit.info/javascript-base64.html - tried using plain text, encoded version on the fly and hardcoded values from other question)
Related questions:
Gmail api with .Net CLient library: Missing draft message [400]
Creating a Gmail Draft with Recipients through Gmail API
Creating draft via Google Gmail API
Handy links just for reference:
Google Developers Console: https://console.developers.google.com/project?authuser=0
Gmail API nodejs: https://github.com/google/google-api-nodejs-client/blob/master/apis/gmail/v1.js
Gmail API overview: https://developers.google.com/gmail/api/overview
Quickstart: https://developers.google.com/api-client-library/javascript/start/start-js
Sample code from repo: https://code.google.com/p/google-api-javascript-client/source/browse/samples/simpleRequest.html
So I'm trying to find a solution in related questions addressing Ruby and C# by recreating JSON structure but I've reached the point that I need a Rubber Duck or Stack Overflow.
Thank you in advance for providing a hint on how to structure the object passed to the API method.
While #rds answer is technically correct: "base64 encode complete message", the fully working answer is as follows... The correct structure of the request:
'draft': {
'message': {
'raw': base64EncodedEmail
}
}
Source: https://developers.google.com/gmail/api/v1/reference/users/drafts/create (scroll down and then choose JavaScript from dropdown menu)
I was missing the essential draft property.
Since the question is the same, the answer will be identical:
'raw' should contain the entire (RFC822) email, complete with body and headers.
The trick is it's not just normal base64 encoding it's WEB SAFE (aka URL SAFE) base64 encoding. It's similar except two characters in the alphabet are different to make sure the entire blob works well in URLs and javascript/json.
Reading the documentation of how to publish the page picture of a facebook page here:
https://developers.facebook.com/docs/graph-api/reference/page/picture/
Is this POST endpoint working?
I am able to get the picture from the
GET /{page_id}/picture?redirect=0&height=200&type=normal&width=200
instead of
GET /platform/picture?redirect=0&height=200&type=normal&width=200
as it says in the docs (It consistently says /platform/ in all examples and ref.).
But whatever I have been trying when POST / Publishing to the endpoint:
POST /{page_id}/picture
with url as a field
I get:
{
"error": {
"message": "(#1) Could not fetch picture",
"type": "OAuthException",
"code": 1
}
}
I tried both through the JS api and through the Graph API Explorer, using the page access token, posting with the url field.
Is this broken in the facebook graph api or am I doing something wrong here?
Step by step:
on the developers.facebook.com/tools/explorer -> Get Access token, and added manage_pages as extended permission
then GET me/accounts to get the page access token for my page (503383593111939): all 6 permissions is there.
copied access_token from me/accounts for page 503383593111939 into the access token input field in the same graph explorer and changed to POST /503383593111939/picture?url=http%3A%2F%2Fwww.wcdouglas.com%2Fimg%2Flogo.png, tried to add the url as a field without urlencode aswell but with the same result
The same happened with me. The only thing was that there was a space character after the query. Removing it would give you the desired result.
Try this query:
GET /{page_id}/picture?redirect=0&height=200&type=normal&width=200
I've just removed the space character in the end.
For post to work, you will have to do something like this:
POST /{page_id}/picture?url=http://images.com/img.jpg
For this, you'll be needing access tokens. You'll get those from here and here.