I able to download an image from facebook conversations using FB API but now i had a problem to download an attached file (.doc, .txt, .log and etc.) from facebook using graph FB API.
Json result return by Facebook if have attached file as below:
"message":"test sent attachment","attachments":{"data":[{"id":"10203275664207489","mime_type":"application/octet-stream","name":"service.log","size":432}]}},
Which is dont have any URL link to the file. But for image that json return by facebook contain url for the that picture. See Json below:
"message":"Gambaq","attachments":{"data":[{"id":"10203185045102068","mime_type":"image/jpeg","name":"10391434_10203185044782060_6466381862586755357_n.jpg","size":null,"image_data":{"width":720,"height":960,"is_sticker":false,"url":"https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpt1/v/t34.0-12/11304104_10203185045102068_881196838_n.jpg?
I use this API code for getting Json result:
dynamic resultsByApi = fb.Get("/" + fbFanPage + "/conversations?access_token=" + tokenPage + "");
My question here is anybody know how to get attached file URL for facebook conversations using FB API?
Can anybody please help me to solve this issues. Thank you in advanced.
To use the REST method to get the attachment data, it's
https://api.facebook.com/method/messaging.getattachment
With expected parameters are:
access_token=YOUR_ACCESS_TOKEN
mid=MESSAGE_ID
aid=ATTACHMENT_ID
format=json //(it defaults to XML otherwise)
{"content_type":"image\/png","filename":"jagadeesh.png ","file_size":14587,"data":<contents of data>}
its working v2.0 is expected..
also look at this fql details
Related
This C# code, with a proper access token (for scope drive.readonly) in the Authorization header, will work fine and return the file metadata in json format
_httpClient.GetAsync($"https://content.googleapis.com/drive/v3/files/{someDriveFileId}")
However this code (still with the same access token) will return a 403 :
_httpClient.GetAsync($"https://content.googleapis.com/drive/v3/files/{someDriveFileId}?alt=media")
And the following response html (exactly as returned) :
<html><title>Error 403 (Forbidden)!!1</title><a
href=//www.google.com/><span id=logo
aria-label=Google></span></a><p><b>403 Forbidden</b><p>Your client
does not have permission.\n
I've been using this code in production for years and it worked fine, so i suppose it's related to the recent changes at Google regarding the OAuth screens ?
I'm not sure what i should change here, or what i'm doing (now) wrong. Also the message seems a little sketchy for something made at Google, makes me think there is maybe an issue on their side ?
UPDATE:
Thanks to #Iamblichus for fixing the layout of my original answer. I'm newer to stackoverflow posting.
Even though the change in the original answer appears to be at the root of the problem, I found it difficult to use the troubleshooting steps to come to a working solution. I also was already passing the Authorization Bearer token solution, and that was not fixing my problem. After some trial and error the change I had to make was:
Broken GET URL:
https://content.googleapis.com/drive/v2/files/MY_FILE_ID?key=MY_KEY&alt=media&source=downloadUrl
Working GET URL:
https://www.googleapis.com/drive/v2/files/MY_FILE_ID?alt=media&source=downloadUrl
NOTE:
I am using v2 of the API, so you would need to update to url to v3 if using that.
In the file object I get from the google filepicker v2 API, I don't get back a single URL that supports the change made in authentication. I had to concat the file.selfLink string to make the new URL work
var url = file.selfLink + "?alt=media&source=downloadUrl";
ORIGINAL ANSWER:
Is it possible that https://cloud.google.com/blog/products/application-development/upcoming-changes-to-the-google-drive-api-and-google-picker-api is your problem?:
download calls to files.get, revisions.get and files.export endpoints which authenticate using the access token in the query parameter will no longer be supported.
Only requests that download media content (alt=media) are affected by this change.
The access token should be provided in the HTTP header, like Authorization: Bearer oauth2-token or, if that's not possible, follow the workarounds provided in the referenced documentation:
For file downloads, redirect to the webContentLink which will instruct the browser to download the content. If the application wants to display the file to the user, they can simply redirect to the alternateLink in v2 or webViewLink in v3.
For file exports, redirect to the export link in exportLinks with the desired mime type which will instruct the browser to download the content.
Reference:
Changes in authorization to Google Drive API
Authorization via HTTP header
v2 files get documentation
v3 files get documentation
im trying to implement Facebook Real Time Update (webhook) , i do all the steps in the Facebook graph API documentation, and the result was JSON contain only few information about the change.
i want to get more information in the JSON result when user upload a delete a photo to his account , like getting new photo id,url or specify what is the real change.
these some photos for my webhook setting and result in codebehind
Webhook image
JSON result in code behind
To get more details, you will have to use the id to fetch the object using Graph API Get request. Then you may be able to compare the result with the previous values. Webhooks returns specific data inside entry object as described in https://developers.facebook.com/docs/graph-api/webhooks
I would like to programmatically retrieve thumbnails of documents from SharePoint. What I'm trying to do is the following:
document.GetImagePreviewUrl(width, height, clientType);
This just returns an empty ClientResult. I am not sure what to enter as clientType value.
I have also tried to use this method programmatically (by using WebClient and downloading the file). But that just returns a 403 response.
The possible solutions I see here are the following:
Figure out what to enter as clientType and retrieve the preview url that way.
Figure out how to tell SharePoint that I am authorized programmatically (using WebClient and headers for instance).
I do need some help regarding these two options, I am not sure where to start since both options aren't well documented.
I've figured out a way to do it, the 403 error was caused because sharepoint had no idea who I was. After some research and fiddling I found out that the request you send to the preview page contains an authentication cookie. This cookie can be generated by code using this piece of code:
// Create an authentication cookie which we can send with the request so sharepoint knows who we are.
var authCookie = credentials.GetAuthenticationCookie(new Uri(imageUrl));
client.Headers.Add(HttpRequestHeader.Cookie, authCookie);
// Download the image data to a byte array
image = client.DownloadData(imageUrl);
I am using file picker apis , i can easily upload my files to there server and they give me a unique url in return . When it comes to again fetch that file its creating a problem to me .
You can tell me how to get back file using that url by using filepicker api .
You can tell me how to use that url and get image , by using c#
When i upload a picture to filepicker.io they return me a json object like following
[{"url":"https://www.filepicker.io/api/file/kIrtNvQRta7GxlFVfiP2","filename":"brazil.jpg","mimetype":"image/jpeg","size":2660,"key":"ZML3OjrFTVyV4waBzRIT_brazil.jpg","isWriteable":true}]
So how to get back that image file using c# / Filepicket javascript api
Edit
In my site user will come and upload many photos , and every link to that photo will be stored in database . Now if user want to see his uploaded pictures then i want to fetch them again from server by url . So give your solutions acc. to this scenario .
Thanks in advance
You could put the picture in a PictureBox first using: PictureBox.Load(string);
After the PictureBox is filled with the image from the url, you can decide what to do next like: saving etc.
PictureBox.Load
I am Working in Asp.net 3.5 with c# 2008.I have done authentication part & I'm also able to get all image URLs or videos from my application. I'm also able to send messages to MySpace. Now I would like to post images & videos.
Please let me know how can I post images/videos from my application.
Here is a link to the Documentation on using Media Items API.
http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
It explains how to use it.
you need to Issue a POST request on following URL
http://api.myspace.com/1.0/mediaItems/{personId}/{selector}/#videos
if its image then set content-type to image/{type} like content-type="image/jpg" for jpg
these formats are supported: .jpg, .gif, .bmp, .tiff, .png.
similarly for videos use content type like content-type=”video/mpeg”
these formats are supported .avi,.mov,.mpg,.wmv.
For more details please consider checking out above link.
For details on what a POST request is or what is its structure check out this http://www.jmarshall.com/easy/http/