How to get image url for specific twitter status - Twitter API - image

I've seen from this post that you can get a user profile image from any of these:
https://twitter.com/[screen_name]/profile_image?size=mini
https://twitter.com/[screen_name]/profile_image?size=normal
https://twitter.com/[screen_name]/profile_image?size=bigger
https://twitter.com/[screen_name]/profile_image?size=original
And that redirects to an image, which works fine. I'm trying to similarly get the image from a status of form
https://twitter.com/[screen_name]/status/894610590915641345/photo/1
This doesn't redirect to anything, and neither does this:
https://twitter.com/[screen_name]/status/894610590915641345/photo/1?size=original
Searching Twitter API brings up only their libraries. Is there a URL to do this?

No, there's no shortcut URL to get the images attached to a Tweet. You'll need to retrieve the Tweet via the API, and then extract the media URLs from the JSON response. Use the statuses/lookup endpoint to get a Tweet by ID.
I'd also suggest using the API to get the user profile image, as the shortcut URL you mention is not officially supported, does not work on mobile, and may be removed in future. Use the users/show endpoint to retrieve a user by screen_name.

Related

Including image URL in Strapi v4 REST API response

First of all I've seen Accessing image url in Strapi and Strapi v4 REST API :GET image and Media field is not showing up in api response of strapi v4 which all tell to add ?populate=* to the request. I am already doing that.
I'm calling my API endpoint http://my-url/api/my-type?populate=* and everything is returned, including everything else but the image URL. I can also confirm that populate=* is working as if I remove it I also stop getting many fields too.
In content manager, I can see the file is uploaded, and is accesible through the obtained URL by tapping "copy link", so the file is there too.
How can I get the image URL in Strapi API request? I'm on Strapi v4.1.8.

Not sure how to download a google drive thumbnailLink using the ruby client

I know how to get the metadata for a google document, and I can get the thumbnailLink value, but I have no clue how to actually download that using the ruby client for the google API. I'm authenticating using an access_token from the user and would like to download the image to represent that document.
I can't find any example or documentation for how to create a credentialed request to do a simple GET of the thumbnailLink URL in ruby.
I have tried adding the Authorization: Bearer <ACCESS_TOKEN> header to the request to no avail.
Any suggestions?
The problem was the scope. The start of this was actually the creation of the google document itself and the scope I used for that was https://www.googleapis.com/auth/drive.file which says "View and manage Google Drive files and folders that you have opened or created with this app", which you would think would give you access to the thumbnailLink for the document you just created with an access_token generated using that scope, but it does not. Instead you need to widen your scope. For now I'm going with https://www.googleapis.com/auth/drive which is pretty much wide open permissions, but will try to limit that later. But once I changed to that scope I'm able to make a simple GET request with the Authorization: Bearer <access_token> header and it works.

facebook image url expires now

I am having a single image url like this but it got expired
https://scontent-a.xx.fbcdn.net/hphotos-xfp1/v/l/t1.0-9/p180x540/14377_340369866155028_6836158858133154924_n.jpg?oh=7ed0d8818ad54fac851b036d24f5e674&oe=55579EE3
After researching about it I came to know facebook changes the signature url of image for security reason and I found a new method to access the image by passing the user id to this link
https://graph.facebook.com//picture?width=600
The new method is also expired now. I am looking for solution so that the link of image don';t gets expire.
What could be the solution?
Have you tried with,
https://graph.facebook.com/v1.0/user_id/picture?width=600
Or according to official documentation of Facebook Graph API, you can make this request using access_token like,
https://graph.facebook.com/v1.0/user_id/picture?width=600&access_token=<access_token>

how to get the base-hostename (blog name) with tumblr api after a successfull oauth-authorization

I have a tumblr api-application and i need to receive infos about a specific blog.
To get this information I need the following request:
api.tumblr.com/v2/blog/{base-hostname}/info?api_key={key}
But I don't know how i get the {base-hostname} from the user who is logged in. Oauth provides just the conusmer-key, the consumer-secret, theo auth-token, and the oauth-token-secret. But i need the blog-name which matches with the user credentials. It works perfectly fine with the tumblr_client gem but due to some reason I am not allowed to use ist.
Can anybody help me with that?
I think you can parse the response from /user/info api (which is based on oauth creds provided for the request). It returns the name / url for the user's blog(s), which you can then use in your {base-hostname}.

How can I make POST requests without making my API key public?

Using the imageshack API I can upload images to imageshack but I have to use an API key to do that. I can create a POST form for the image upload to imageshack but the key has to be put in the form and that exposes the API key publicly. How can I upload images to imageshack without exposing my API key?
I think the only way to do this properly is that the image is first POSTed to your OWN application by the user.
Then in your app you internally redirect this POST to ImageShack, where you can use your API key safely without anyone ever seeing it.
You can use something easy like RestClient to run the POST request from your back-end. You will need to store the image temporarily on your server, either in memory or on disk, for retransmission to ImageShack.
So:
User sends image with POST to your server
Your server receives the image in the POST request from the user
Your server runs a POST with this image to ImageShack using your API key
The POST request from step 1 returns successfully to the user

Resources