Where is the full size image in GData.Photos query? - c#

I am querying a Picasa gallery and when I dig into the entries that are returned, I can't find the full size image. I can only see a much smaller, re-sized image (data[0].Content.AbsoluteUri). I know Google retains the full size image because I can see it when I view my Picasa gallery online. Where is the full size image?
var picasaService = new PicasaService("Gallery");
var photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri("GOOGLEUSERNAME", "GALLERYID"));
var photoFeed = picasaService.Query(photoQuery);
var data = photoFeed.Entries;

Hidden in the documentation it is possible to specify the size of the images in the feed. This is using the "imgmax" parameter:
https://developers.google.com/picasa-web/docs/2.0/reference#Parameters
Which can have a value set to "d" to request full sized images
This is not supported directly in the c# API, but you can achieve the desired result using the "extraParameters" field on the PhotoQuery object.
Your code then becomes:
var picasaService = new PicasaService("Gallery");
var photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri("GOOGLEUSERNAME", "GALLERYID"));
// add the extra parameter to request full size images
photoQuery.ExtraParameters = "imgmax=d";
var photoFeed = picasaService.Query(photoQuery);
var data = photoFeed.Entries;

short answer:
media:group/media:content[#url] path in a query to get the gdata photo ENTRY from the picasa GData service contains the link you want.
Longer answer:
interactively query the Gdata api for picasa using oauth playground\
https://code.google.com/oauthplayground and select picasa from the list and get
authorize button ... then allow access button and you can query the api using the form
make a query for the ENTRY URI of desired photo (your ...user/.. /albumid .. /photoid )
inspect the content of media:group/media:content[#url] sample below
The URI to the big photo is valueOf the url attribute in the above expression
sample value for one of my picasa photos
url=https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG
Using the oauth 2.0 playground for a query to get the entry of one of my photos...
Request:
GET /data/entry/api/user/rowntreerob/albumid/5682316071017984417/photoid/5682316083381958690?alt=json
Note: filter response using http://json.parser.online.fr/
Response:
"media$group":{
"media$content":[
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG",
"height":512,
"width":341,
"type":"image/jpeg",
"medium":"image"
}
The link to the large photo that you want is in the url attribute above...
Using the "fields=" tag, you can directly get the link as in below req/ resp from gdata...
GET /data/entry/api/user/rowntreerob/albumid/5682316071017984417/photoid/5682316083381958690?alt=json&fields=media%3Agroup%2Fmedia%3Acontent%5B%40url%5D
{
"version":"1.0",
"encoding":"UTF-8",
"entry":{
"xmlns":"http://www.w3.org/2005/Atom",
"xmlns$media":"http://search.yahoo.com/mrss/",
"media$group":{
"media$content":[
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG",
"height":512,
"width":341,
"type":"image/jpeg",
"medium":"image"
}
]
}
}
}

Related

How to use a Google Drive stored jpeg image in a replaceImage Google docs request?

I am building a google document from Google docs API.
My doc is created from a template: copy the template in new location, replace texts, and replace images.
Everything is OK until I try to replace my images.
The images to put in the file are stored in a Google Drive folder.
So, I have 2 questions:
the first one is how to use replaceImage request with viewing URL of my image?
By using following code, I am facing a 400 error.
IDictionary<string, InlineObject> inlineObjects = doc.InlineObjects;
//Get the objet ID
string imageObjectId = inlineObjects.First().Value.ObjectId;
BatchUpdateDocumentRequest batchUpdateRequest = new BatchUpdateDocumentRequest {
Requests = new List<Google.Apis.Docs.v1.Data.Request>()
};
var request = new Google.Apis.Docs.v1.Data.Request {
ReplaceImage = new ReplaceImageRequest() {
ImageObjectId = imageObjectId,
Uri = "https://docs.google.com/uc?export=view&id=1pmXP9TFolKMQoUlXHllvIrQPlZiDxId6"
}};
batchUpdateRequest.Requests.Add(request);
DocumentsResource.BatchUpdateRequest updateRequest =
_docSercive.Documents.BatchUpdate(batchUpdateRequest, fileId);
BatchUpdateDocumentResponse updateResponse = updateRequest.Execute();
Error:
Invalid requests[0].replaceImage: Access to the provided image was forbidden. [400]
Errors [
Message[Invalid requests[0].replaceImage: Access to the provided image was forbidden.] Location[ - ] Reason[badRequest] Domain[global]
]'
and the second one is, how to industrialize this by retriving image URL from Google Drive API?
When I try getting it right now, I can only access image name and extension:
Google.Apis.Drive.v3.Data.File f = _service.Files.Get(fileId).Execute();
am I supposed to use query params for this file.get call?
Thanks for your help!

Upload Image To Collection Using InstaSharp or InstagramApiSharp?

I want to upload images to my Instagram account using an Api like InstaSharp or InstagramApiSharp on Github and C#. But have no idea how to do it.
There is UploadPhotoAsync() but can't specify what collection it should be uploaded to.
Anyone have any solutions?
You just pass InstaImage and String for caption.
InstaImage iamge = new InstaImage
{
URI = new Uri(Path.GetFullPath("image.jpg"), UriKind.Absolute).LocalPath,
Width = 720,
Height = 889,
};
IResult<InstaMedia> postResult = await _instaApi.UploadPhotoAsync(iamge,"caption");

Post Image on Instagram with API using c#

I am building a Asp.net C# application i want to post the user uploaded picture directly to Instagram, but after a quick search i can not found any function in the API somebody help me how to post image on instagram wall by C# code
Below Code I can Get Access Token
private void Authentication()
{
string rest = string.Empty;
GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"], "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
oAuthInstagram _api = oAuthInstagram.GetInstance(config);
rest = _api.AuthGetUrl("likes+comments+basic+relationships");
Response.Redirect(rest);
}
// Call back Url
public ActionResult Instagram()
{
string code = (String)Request.QueryString["code"];
oAuthInstagram objInsta = new oAuthInstagram();
GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
oAuthInstagram _api = new oAuthInstagram();
_api = oAuthInstagram.GetInstance(configi);
AccessToken access = new AccessToken();
access = _api.AuthGetAccessToken(code);
string accessToken = access.access_token;
string id =access.user.id;
ViewBag.accessToken = accessToken;`enter code here`
ViewBag.Uid = id;
return View();
}
Below Code i have get Access Token and Profile ID
How To Post Image ? some body tall me
You cannot upload photos to Instagram through the API. From Instagram's API documentation https://instagram.com/developer/endpoints/media/:
At this time, uploading via the API is not possible. We made a
conscious choice not to add this for the following reasons:
Instagram is about your life on the go – we hope to encourage photos from within the app.
We want to fight spam & low quality photos. Once we allow uploading from other sources, it's harder to control what comes into the
Instagram ecosystem. All this being said, we're working on ways to
ensure users have a consistent and high-quality experience on our
platform.

Getting hashcode for image in facebook ads api

I'm trying to get hash image using the Facebook Ads api.
I didn't understand how to make the call.
I have the image Url as string and the image itself as Byte[].
This is the example from FB documentation:
curl -F 'test.jpg=#test.jpg' -F 'access_token=_' "https://graph.facebook.com/act_368811234/adimages"
What is the test.jpg=#test.jpg means ? It's not something that I've seen before.
You can find the relevant Facebook documentation URL at: https://developers.facebook.com/docs/reference/ads-api/adimage/
Thank you
The following part of the curl request means post a parameter named test.jpg which references a local file path within the current directory called test.jpg.
test.jpg=#test.jpg
If you're using c#, you may want to take a look at the open source library available from facebooksdk.net (note, it's not produced by Facebook):
http://facebooksdk.net/docs/making-synchronous-requests/
Using this, it will likely be a couple of lines of code:
var fb = new FacebookClient("access_token");
string attachementPath = #"C:\\image.jpg";
dynamic result = fb.Post("act_YOURACCOUNTID/adimages",
new
{
file = new FacebookMediaObject
{
ContentType = "image/jpeg",
FileName = Path.GetFileName(attachementPath)
}.SetValue(File.ReadAllBytes(attachementPath))
}
);
As you also tagged PHP, you can use the Facebook SDK which is produced by Facebook with the following code: https://github.com/facebook/facebook-php-sdk/
$facebook = new Facebook(array(
'appId' => 'YOUR_APPID',
'secret' => 'YOUR_APPSECRET',
));
$facebook->setAccessToken("YOUR_ACCESS_TOKEN");
$facebook->setFileUploadSupport(true);
$file='./test.jpg';
$args = array(
basename($file) => '#' . realpath($file),
);
$response = $facebook->api('/act_YOURACTID/adimages','post',$args);

How to use Bing as the search engine on my site?

Does Bing has an option similar to Google Custom Search or Yahoo where I can use Bing to power the search results on my site?
Couple requirements:
Works with an ASP.NET site (is a .NET project)
Host the search box and results on my own website
Ability to customize the look and feel of the results to match my site (Full control is ideal but I understand it's not possible with free solutions)
I did a search for Bing custom search and found this: http://www.bing.com/siteowner/ but it's not exactly what I am looking for.
The query string Bing uses is:
http://www.bing.com/search?q=&src=IE-SearchBox&FORM=IE8SRC
(this is the template URL from the Bing search provider in IE). All you have to do is insert your search terms after the q parameter. A good way to test this is to actually execute a search and see the url in the address box of the browser:
http://www.bing.com/search?q=how+to+query+bing&src=IE-SearchBox&FORM=IE8SRC
you can drop the src and FORM parameters, Bing will just be using those for statistical purposes.
To get the results to appear in your own page, use an iframe, give it an id, and sets its src url (using javascript) to the search url you have constructed.
var frame = document.getElementById('mySearchFrame');
if (frame != null)
frame.src = 'http://www.bing.com/search?q=' + mySearchTerms;
Note that if you want to style the page then you will have to query Bing from code behind and "scrape" the results and place them into your own page. (Or you could just send the page back but modify the contents of it before doing so, but to do this will be violating Bing's terms of use - MS supply Bing for you to use for free, but it is on their terms, which means you will not be able to delete any advertising or change the look and feel of the page - there are no free rides in this world :).
You can sign up for site search and query Bing via jsonp and display results via javascript (exact code untested)
function searchDone(results) {
if(results.SearchResponse.Web.Results && results.SearchResponse.Web.Results.length > 0) {
for (var i = 0; i < results.SearchResponse.Web.Results.length; i++) {
result = results.SearchResponse.Web.Results[i];
item = document.createElement('li');
item.innerHTML = '' + AntiXssLibrary.HtmlEncode(result.Title.replace(/\uE000/g, "").replace(/\uE001/g, "")) + '' + '<blockquote>' + AntiXssLibrary.HtmlEncode(result.Description.replace(/\uE000/g, "").replace(/\uE001/g, "")) + '</blockquote>';
// append child to document somewhere
}
}
}
var serviceURI = "http://api.search.live.net/json.aspx?JsonType=callback&JsonCallback=searchDone&sources=web&Options=EnableHighlighting";
var appid = "&Appid=YOUR_BING_APP_ID";
var query = "&query=site:http://YOURDOMAIN.com/ <%=Request.Querystring["query"] %>";
var fullUri = serviceURI + appid + query;
var head = document.getElementsByTagName('head');
var script = document.createElement('script');
script.type = "text/javascript";
script.src = fullUri;
head[0].appendChild(script);

Categories

Resources