Checking if a instagram image is private - api

Say I have the URL to an image, http://instagr.am/p/xxxxxxxx/, how can I check if the image is set to private or not from a webpage? Is there some API that I can use?
I need this since I have a bunch of Instagram images that I show on my page, but I want to remove the link to them if they become private.

I did not find a way to see if a specific image was private or not, so instead i save the AuthorID of the image. If this author has a private profile i will get an exception when trying to get the user information, and if i get an exception, then i know i can remove the link to the image.
This is my powershell-code i use:
try
{
Invoke-WebRequest "https://api.instagram.com/v1/users/<InsertAuthorID>/?client_id=xxxx";
}
catch [Exception]
{
# Remove Image
}

Use the GET relationship endpoint.
https://api.instagram.com/v1/users/user-id/relationship
This endpoint returns a BOOL value "target_user_is_private".

Related

How to obtain the media-id from an instagram image url

I am trying to obtain the media id of an image so I can use this to gather insight information from a new API call: GET /{ig-media-id}/insights?metric={metric}
I have tried retrieving the media id using this request: http://api.instagram.com/oembed?callback=&url={image url} ... however, the media_id in the response is not valid for the insights API call.
Does anyone know how to get a valid media id or how to use the one returned in the above request?
<meta property="al:ios:url" content=
found in the meta property of the page view-source
adding to the earlier answer
inspect element >> search for "al:ios:url" >> it's in the string followed by content =
-> instagram://media?id=2905947356079086246

How do I just add a custome variable to a Survey Monkey?

I am handling existing surveys via the API.
As part of this, I need each survey to have a custom variable defined for it.
I would like to use the API to add the custom variable, but the documentation states the FETCH would not do that, and PUT will replace rather than update the survey.
I am handling existing surveys, which I would not like to delete and replace, or am I miss-reading the docs?
Can I just send via PUT the following structure and it will keep everything else in place?
{
id : 112223333, //id of survey
custom_variables: {
'custom1':'custom1',
'custom2':'custom2'
}
}
I do see it resets the title, so, is this method safe? (i.e. wont remove any other data associated to this survey).
You're on the right track. You're going to want to use a PATCH HTTP request. That will only make updates, whereas a PUT request will replace the survey with the content you provide.
So your request will likely look something like this:
PATCH /v3/surveys/<survey_id>
{
"custom_variables": {
"custom1_name": "custom1_label",
"custom2_name": "custom2_label"
}
}
And that should only update your custom variables to the values you set. The docs do appear to suggest custom_variables won't get updated with a PATCH request but I think it does work.

Google Search Image "no longer available: 403" [duplicate]

I am using google image search API. Till yesterday it was working, but today morning it says "This API is no longer available"
Is it officially closed, Or any error at my side
Request
https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q=cute+kittens
Response
{"responseData": null, "responseDetails": "This API is no longer available.", "responseStatus": 403}
The answer I found was using Google's Custom Search Engine (CSE) API. Note that this is limited to 100 free requests per day.
Creating cx and modifying it to search for images
Create custom search engine at https://cse.google.com/cse/create/new based on your search criteria.
Choose sites to search (leave this blank if you want to search the entire web, otherwise you can enter a site to search in one particular site)
Enter a name and a language for your search engine.
Click "create." You can now find cx in your browser URL.
Under "Modify your search engine," click the "Control Panel" button. In the "edit" section you will find an "Image Search" label with an ON/OFF button, change it to ON. Click "update" to save your changes.
Conducting a search with the API
The API endpoint url is https://www.googleapis.com/customsearch/v1
The following JSON parameters are used for this API:
q: specifies search text
num: specifies number of results. Requires an integer value between 1 and 10 (inclusive)
start: the "offset" for the results, which result the search should start at. Requires an integer value between 1 and 101.
imgSize: the size of the image. I used "medium"
searchType: must be set to "image"
filetype: specifies the file type for the image. I used `"jpg", but you can leave this out if file extension doesn't matter to you.
key: an API key, obtained from https://console.developers.google.com/
cx: the custom search engine ID from the previous section
Simply make a GET request by passing above parameters as JSON to the API endpoint (also listed above).
Note: If you set a list of referrers in the search engine settings, visiting the URL via your browser will likely not work. You will need to make an AJAX call (or the equivalent from another language) from a server specified in this list. It will work for only the referrers which were specified in the configuration settings.
Reference:
https://developers.google.com/custom-search/json-api/v1/reference/cse/list
Now You can search images with Custom image search API.
You can do this with two steps:
Get CUSTOM_SEARCH_ID
Go to - https://cse.google.ru/cse/all
Here you must create new Search Engine. Do this and enable Image Search at there.
Screen(i am Russian... sorry)
then get this search engine ID. To do this press at Get Code button:
And there find line with cx = "here will be your CUSTOM_SEARCH_ID":
Ok. It's done, now second step:
Get SERVER_KEY
Go to google Console - https://console.developers.google.com/project
Press to Create project button, enter the name and other required information.
Pick this project and go to Enable Apis
Now find Custom Search Engine.
And Enable it.
Now we must go to Credentials and create new Server Key:
Ok. Now we can use Image Search.
Query:
https://www.googleapis.com/customsearch/v1?key=SERVER_KEY&cx=CUSTOM_SEARCH_ID&q=flower&searchType=image&fileType=jpg&imgSize=xlarge&alt=json
Replace the SERVER_KEY and CUSTOM_SEARCH_ID and call this request.
Limit: for free you can search only 100 images per day.
If this is just for your own purposes (not for production) and you're not planning to abuse Google Image Search, you can simply extract first image URL from Google search results using JSOUP.
For example:
Code to retrieve image URL of the first thumbnail:
public static String FindImage(String question, String ua) {
String finRes = "";
try {
String googleUrl = "https://www.google.com/search?tbm=isch&q=" + question.replace(",", "");
Document doc1 = Jsoup.connect(googleUrl).userAgent(ua).timeout(10 * 1000).get();
Element media = doc1.select("[data-src]").first();
String finUrl = media.attr("abs:data-src");
finRes= "<img src=\"" + finUrl.replace("&quot", "") + "\" border=1/>";
} catch (Exception e) {
System.out.println(e);
}
return finRes;
}
Guide:
question - image search term
ua - user agent of the browser
After I read several responses I compiled a response with images:
Access the website: https://developers.google.com/custom-search/v1/introduction, on the page you will find this part, so click in the button Get a Key:
Create or select a project, and then NEXT:
Copy the API KEY:
Access the website to create your CX: https://cse.google.com/cse/create/new, write some random domain like “www.anypage.com”, (after we will delete), select a language, and define some name for your search engine. Click on the Button CREATE.
Will see this page, then click in Control Panel:
Copy the Search engine ID for later (this is your CX). After you can set to search in all websites (active Search the entire web, select on the random website www.anypage.com then click on the button Delete) and you can active Image search. So will see like this:
And Using REST you can get the results, using this example code (searching for flower):
<html lang="pt">
<head>
<title>JSON Custom Search API Example</title>
</head>
<body>
<div id="content"></div>
<script>
function hndlr(response) {
console.log(response);
for (var i = 0; i < response.items.length; i++) {
var item = response.items[i];
// in production code, item.htmlTitle should have the HTML entities escaped.
document.getElementById("content").innerHTML += "<br>" + item.htmlTitle;
}
}
</script>
<script src="https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=SEARCH_ENGINE_KEY&q=flower&searchType=image&callback=hndlr"></script>
</body>
</html>
The base code is found here: https://developers.google.com/custom-search/v1/using_rest
After setting your API_KEY (key) and your SEARCH ENGINE KEY (cx), the result will see like this:
Thanks to #Vijay Shegokar, #aftamat4ik and #Alladinian
This is the full URL template to be used
We can eliminate unnecessary parameters.
https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json
I am using
https://www.googleapis.com/customsearch/v1?key=ap_key&cx=cx&q=hello&searchType=image&imgSize=xlarge&alt=json&num=10&start=1
Change the API url to
Google Custom Image search
Provide the same parameters along with with API KEY and CX.
More Info and Explorer
The Yahoo Boss API is a reasonable substitute, although it's not free and the results are not quite as good.
UPDATE: YAHOO BOSS JSON Search API will discontinue on March 31, 2016
SerpAPI enables to search through Google Images and returns a clean json. it integrates with most of the programming languages: python, php, java, golang, nodejs...
https://serpapi.com/images-results
Google limit the number of search per day.
but this service provides unlimited searches...
looks like we need to implement google custom search API
https://developers.google.com/custom-search/
says so on top of the page you provided yourself

How to get images from Blizzard Community Platform

We can get some information by json.
But how can i get images by the information in json.
e.g. "thumbnail": "medivh/1/1-avatar.jpg"
It does not work when i concat the url behind the host + request.
So, is there some other way to get images?
The url for the static images has the following format:
http:// REGION . battle.net/static-render/ REGION / THUMBNAIL
Example:
For the avatar image
http://eu.battle.net/static-render/eu/alexstrasza/57/51685945-avatar.jpg
The picture you see when you visit your armory profile
http://eu.battle.net/static-render/eu/alexstrasza/57/51685945-profilemain.jpg
Another angle, I don't know where this is used
http://eu.battle.net/static-render/eu/alexstrasza/57/51685945-inset.jpg
As of the latest changes to the static renderer, the following is correct:
http://render-<Region>.worldofwarcraft.com/character/<Thumbnail>
For example:
http://render-us.worldofwarcraft.com/character/kul-tiras/148/130814612-profilemain.jpg

What does visibleContentsAsDataURL exactly do?

I am currently trying to build my first Safari extension. The SafariBrowserTab Class has a Method called "visibleContentsAsDataURL".
I don't exactly understand what it does and can't get it to work.
The docs just say: "Returns a data URL for an image of the visible contents of the tab."
What does it mean? That I get the URL of a screenshot of the tabs' content back? Can someone explain me?
Thanks!
I think it returns what is effectively a screenshot of the tab. The format is explained here
http://en.wikipedia.org/wiki/Data_URI_scheme
According to Apple's Safari reference documentation the return value is "a base-64 encoded PNG."
A data URL is a specal type of url basically consisting of a mimetype and data, in the case of png you'll get something along the lines of:
data:image/png;base64;lotsofstuff
You can then do whatever you want with it (it's just a string), or if you want to display the content:
img = new Image();
img.src = someTab.visibleContentsAsDataURL();
someElement.appendChild(img);
or
someCanvasContext.drawImage(img);
etc