How to upload photo to Facebook via graph api - facebook-graph-api

i am having a desktop application. My requirement is to upload photo to facebook using graph api. I am able to post message to user wall via application. But i am not able to upload photo. i am getting an error "EXPECTS UPLOAD FILE" . i went through the documentation specified in the link
http://developers.facebook.com/blog/post/498/
I am using Winhttp for the connection. So how the file name will be specified? Whether the file name be specified in the URL itself?'
Please help me out

Specify the paraemeters message and source as multipart/form-data and send it with winhttpsendrequest

Related

Refreshing Video CDN link on Instagram with Graph API

Is there anyway to refresh the link of a video on instagram legally?
When I say legally I mean not via scraping but by following developer guidelines on https://developers.facebook.com/docs/graph-api ?
Suppose I was looking to get the following reel: https://www.instagram.com/reel/Cg3D38GBJwC/
I can get this raw video via the #NRL hashtag recent media which can be pulled with the following request:
17841564583099740/recent_media?fields=permalink,caption,media_type,media_url&limit=50
The video URL for this reel is:
https://video.cdninstagram.com/v/t50.33967-16/10000000_893382015382741_7795625665889045256_n.mp4?_nc_cat=104&vs=480915650532430_3376026638&_nc_vs=HBksFQAYJEdJQ1dtQURWOUt5MWhpd0RBQWdMUEhrOW9DOXNicV9FQUFBRhUAAsgBABUAGCRHSjJRdXhIa1cxMkd5RWNHQUM2WWRqa2xld1pRYnFfRUFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAACagzLv9gdHNPxUCKAJDMywXQHRVul41P30YEmRhc2hfYmFzZWxpbmVfMV92MREAdQAA&ccb=1-7&_nc_sid=59939d&efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5jbGlwcyJ9&_nc_ohc=p8ThcVQ1vOQAX8njt1u&_nc_ht=video.cdninstagram.com&edm=AEoDcc0EAAAA&oh=00_AT8IoyJDBQLTOX1hXpby3lCT6cIiIcxuDTJUXaWlrrcCZA&oe=62ECFBB6&_nc_rid=e2b1a3ee71
We can initially obtain this URL by using the /recent_media endpoint, but after a day or so it will expire as it has the expiry embedded in the oe parameter.
Is there anyway I can refresh the link of this video by making another request?

LINKEDIN api : Invalid file name while uploading the photo url

For posting multiple photos, I need to upload the photos with the following api
https://api.linkedin.com/media/upload
passing image through url. But getting the above error
As it accepts multipart/form-data, Need to change the type to file.

Can't send PATCH request to Vimeo API

I am trying to send a PATCH request to the Vimeo API in order to start uploading the video based on the documentation.
I am using Postman. I've read {upload.upload_link} field, set the required headers but I still can't hit the API.
Does anyone know what could be the problem?
Try making that PATCH request again, but without the Authorization or Host headers, as they are not required for that upload endpoint:
https://developer.vimeo.com/api/upload/videos#resumable-approach-step-2

serving user content/images from amazon s3

I am building an app which lets users upload pictures and share it with his/her friends only.
I am using spring restful services to upload content directly to s3.
The user is authorized using OAuth.
To upload an image an authorized user's js client invokes POST /images/{userid}
To download the image, the client has to invoke GET /images/{userid}/{imageid}
Each user's content is stored in s3 under his own folder name, and the downloading service as explained in point 4 is the one that has to be invoked. Unfortunately, this means I cannot assign this url as source to an image tag <img src="">, because the authorization token should be sent on GET request. I cannot make the contents of user folder public because only user and his friends are allowed to see the images. The current service will soon become a bottleneck and I would like to avoid that.
What is the recommended architecture/design to solve this problem?
Instead of having a service that loads and returns the entire image file from S3, you should have a service that simply generates an S3 presigned URL. Then the URL retrieved from that service can be used in the <img src=""> tags on your site. This will be much more performant since the web browser will ultimately download the image directly from S3, while also still being secure.
The flow for downloading the images would be like this
User invokes GET request to download image
At Server End
Authenticate user
Query DB for metadata
Create a time based auth token.
Create a image URL(S3 based) and append auth token created in previous step
At the client end(User browser) redirect user to new URL(this url is effectively S3 location+auth token )
Now direct request will comes at the server( image URL+ auth token)
authenticate the token and then show image to user
Above URL will not be valid for long time , but your images are secured. As auth token is time based it will cater your case like if some one make the image private/public remove a friend.Deleted images , Copy paste of image url etc ..

Media Builder Not Found Exception while Publishing into Instagram using Graph API

We are oftenly getting "Media Builder Not Found" Exception while publishing media using Instagram Graph API.Can anyone know how to fix it?
Triggered URL:
Url1 : https://graph.facebook.com/v2.10/<userId>/media?access_token=<token>&image_url=<imageUrl>
&caption=<caption>
Url2 : https://graph.facebook.com/v2.10/<userId>/media_publish?creation_id=<creationId>&access_token=<token>
Yeah, this is tricky and sad - Facebook really has outdone itself here. The issue is that uploading to Instagram using Facebook API requires 2 types of access tokens.
When you call /media endpoint to upload an image, a user access token must be used.
When you use /media_publish to publish a previously created image - you must use page access token
Good luck!
I had the same issue, in my case, using the page token to create the media object and then using the user token to publish it, solved it.
What's strange though is that before I got the Instagram permissions approved, everything worked just by using the page token...but after I got the permissions approved it started failing and I had to use the user/page token combination to make it work.