Instagram MediaID/Shortcode to URL - instagram-api

I'm making a sequence of API calls to Instagram Graph API in order to publish an image.
As described in their docs I'm making two calls as follows:
POST https://graph.facebook.com/API_VERSION/IG_USER_ID/media
with params:
{
access_token: IG_USER_ACCESSTOKEN,
image_url: "https://cdn0.iconfinder.com/data/icons/social-media-square-4/1024/instagram-512.png",
caption: "Caption goes here",
}
returns:
{ id: 17859694922405416 }
Then I get the media container id from this call and I make another one to publish it:
POST https://graph.facebook.com/API_VERSION/IG_USER_ID/media_publish
with parameters:
{
creation_id: CONTAINER_ID_TAKEN_FROM_THE_PREVIOUS_CALL,
access_token: IG_USER_ACCESSTOKEN
}
This returns another ID which then I convert into a shortcode (using a function I found handy).
{
id: '17872941842175967',
id_str: '17872941842175967',
}
Result shortcode is : _f1iNmBff
I cannot seem to find the proper URL to see that image in the browser.
I've tried with: https://www.instagram.com/p/_f1iNmBff/, but it says that the page cannot be found.
I've even tried to check on the media container status with another call and it says that the status is FINISHED (but not PUBLISHED).
Any idea what the problem is?

Related

Incomplete API response for getUsers

I'm implementing an API integration for DocuSign, and I'm currently hitting the following endpoint: /v2/organizations/{organizationId}/users
The documentaton for this: https://developers.docusign.com/docs/admin-api/reference/users/users/getusers/#response200_docusign.api.organizations.web.models.restapi.v2.response.organizationuserresponse
The documentation is showing a response field, user_status. However, when I call the API, I get a response as follows:
{
"users":[
{
"id":"xxx-xxx-xxx-xxx-xxx",
"user_name":"Xxxx",
"first_name":"",
"last_name":"Xxxx",
"membership_status":"active",
"email":"xxxx#gmail.com",
"membership_created_on":"2021-07-30T02:24:20.243",
"membership_id":"xxxx-xxxx-xxxx-xxxx-xxxx"
},
{
"id":"yyy-yyy-yyy-yyy-yyy",
"user_name":"Yyyyy",
"first_name":"Yyyyy",
"last_name":"2",
"membership_status":"active",
"email":"yyyyyyy#yyy.yyy",
"membership_created_on":"2021-07-30T02:26:59.313",
"membership_id":"yyy-yyy-yyy-yyy-yyy"
},
{
"id":"zzz-zzz-zzz-zzz-zzz",
"user_name":"Zzzzz",
"first_name":"Zzzz",
"last_name":"Zzzz",
"membership_status":"active",
"email":"zzz#zzz-zzz.net",
"membership_created_on":"2021-07-15T04:05:18.803",
"membership_id":"zzz-zzz-zzz-zzz-zzz"
}
],
"paging":{
"result_set_size":3,
"result_set_start_position":0,
"result_set_end_position":2,
"total_set_size":3
}
}
As you can see, we have no user_status. Do we need to send any request parameters, to expand the response, or has this field been removed from the API response without being updated on the API documentation?
Or, could I assume that the user is active, if it appears in the API response, with a membership_status of active?
Thank you very much!
membership_status is probably what you're looking for.
there's no such thing as user_status because a user can be a member of multiple accounts and each membership can have a different status.
Here is a useful diagram:

How to get the comments from a GitHub pull request using GitHub API?

I am trying to get the comments on a pull request using GitHub API, for example:
https://api.github.com/repos/mapra99/members-only/pulls/1/comments
But it returns an empty array.
The same if I try to use the review comments endpoint:
https://api.github.com/repos/mapra99/members-only/issues/1/comments
Although there is a comment on that pull request:
https://github.com/mapra99/members-only/pull/1
How can I get the comment that is on that pull request using GitHub API? Why is it not possible to get if from any of those endpoints?
In fact, this is not a comment but a review :
Pull Request Reviews are groups of Pull Request Review Comments on the
Pull Request, grouped together with a state and optional body comment.
You can get the reviews using :
https://api.github.com/repos/mapra99/members-only/pulls/1/reviews
Or using GraphQL v4 to get reviews & comments :
{
repository(owner: "mapra99", name: "members-only") {
pullRequest(number: 1) {
reviews(first: 100) {
nodes {
body
}
}
comments(first: 100) {
nodes {
body
}
}
}
}
}

Issue in binding kendo grid with web api hosted on Azure

I am struggling in order to bind the kendo grid with Web API. Web API is hosted in the Azure worker role (not yet published). And the Web API is decorated in order to work with the cross domains i.e Enabled CORS for the Web API.
Let us look the code I have written.
Action method in the Web API look like the following.
public JToken Get()
{
JToken json = JObject.Parse(
"{ \"firstName\": \"John\",
\"lastName\": \"Smith\",
\"isAlive\": true,
\"age\": 25,
\"height_cm\": 167.6,
\"address\":
{
\"streetAddress\": \"21 2nd Street\",
\"city\": \"New York\",
\"state\": \"NY\",
\"postalCode\": \"10021-3100\"
},
\"phoneNumbers\":
[{
\"type\": \"home\",
\"number\": \"212 555-1234\"
},
{
\"type\": \"office\",
\"number\": \"646 555-4567\"
}]
}"
);
return json;
}
When I execute this web api we will get the emulator with the IP address as "127.0.0.1" and I used the controller "TestController".
When I execute the above api in the browser, I am getting the JSON data perfectly, but when I use the same to bind the grid, all is vain.
The code used to bind the data is
$("#dw_report_container1").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "http://127.0.0.1/test",
dataType: "json"
}
},
},
height: 500,
scrollable: true,
selectable: true
});
I am getting no exception.
Finally, after a long struggle i got the solution :(. I find a strange thing when working with the kendo grid. Whenever we work with the models inside our project and returned the model to the datasource of the kendogrid, it internally creates a model for it. As i worked with sample json as above, it (kendogrid) doesn't create the model for the grid to bind. Hence the problem occurs. Eventually, what i concluded that it is better to have a schema/model in the datasource (kendo grid). Past i didn't :( Thank you.

Get GitHub avatar from email or name

I'm trying to get the GitHub user picture (avatar) from users of GitHub.
I've found these API:
https://avatars.githubusercontent.com/<username>
https://avatars.githubusercontent.com/u/<userid>
But I can't find a way to get the avatar from the user email or the user display name.
I can't find documentation about that.
Is there some similar URL API to get what I'm looking for?
You can append .png to the URL for the User's profile to get redirected to their avatar. You can add the query param size to specify a size smaller than the default of 460px wide (i.e. it won't allow larger than 460).
Examples:
https://github.com/twbs.png
https://github.com/npm.png?size=200
https://github.com/github.png?size=40
https://developer.github.com/v3/users/#get-a-single-user
Use the /users/:user endpoint. Should be under avatar_url in the returned json.
For example, my avatar_url can be found by hitting this url.
Edit
There is another way I can think of that is kind of roundabout. Since GitHub uses Gravatar, if you know the email associated with the account, do an md5 hash of the lowercase, stripped email address and construct a url like http://www.gravatar.com/avatar/[md5_here].
This is an old post but nobody has proposed Github Search Users API with scope field :
using in:email : https://api.github.com/search/users?q=bmartel+in%3Aemail
using in:username : https://api.github.com/search/users?q=Bertrand+Martel+in%3Ausername
Or using new Graphql API v4 :
{
search(type: USER, query: "in:email bmartel", first: 1) {
userCount
edges {
node {
... on User {
avatarUrl
}
}
}
}
}
Using GraphQL API v4, this will work too
Query (for username)-
{
user(login: "username") {
avatarUrl
}
}
Response -
{
"data": {
"user": {
"avatarUrl": "https://avatars1.githubusercontent.com/u/..."
}
}
}
GitHub avatar can be accessed through https://avatars.githubusercontent.com/u/YOUR_USER_ID
Optionally, you can modify the size at the end like so https://avatars.githubusercontent.com/u/YOUR_USER_ID?s=460

how to get "my pull requests" from github api?

If you look at: http://developer.github.com/v3/pulls/ it shows you how to get pull requests for a given repository.
How do we get "my pull requests" from the GitHub API similar to the data displayed on the GitHub dashboard?
I asked Github directly. A rep told me to use the search endpoint. Search for issues owned by you that are open and of type pr.
https://api.github.com/search/issues?q=state%3Aopen+author%3Adavidxia+type%3Apr
If you're using a python client lib like Pygithub you can do
issues = gh.search_issues('', state='open', author='davidxia', type='pr')
You can also use GraphQL API v4 to get all your pull requests :
{
user(login: "bertrandmartel") {
pullRequests(first: 100, states: OPEN) {
totalCount
nodes {
createdAt
number
title
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
Try it in the explorer
or using viewer :
{
viewer {
pullRequests(first: 100, states: OPEN) {
totalCount
nodes {
createdAt
number
title
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
First you have to realize that you must authenticate using either Basic Authentication or a token. Next you have to realize that there is no simple way to do this so you will have to be clever.
To be specific, if you probe https://api.github.com/issues, you'll notice that the issues there have a hash called pull_request which should have 3 URLs: html, diff, and patch. All three will be non-null if the issue is also a Pull Request. (Pro-tip: They're the same thing as far as GitHub is concerned…sort of.)
If you iterate over your issues and filter for ones where those attributes are not null, then you'll have your pull requests.

Resources