How to avoid delay when displaying Picasa photos using Picasa API? - httpwebrequest

I’m currently working with the Google Picasa API (C#) to display photos from public Picasa web album on my website.
The issue is that there is a delay (seconds to minutes) from the moment changes are done in web album to the moment it is reflected via API.
I need it to be reflected immediately: When new photo is uploaded to the album I need it to be displayed on the same time exactly in the web site.
It got even more interesting when I found out changes are displayed without delay when entering the URL (http://picasaweb.google.com/data/feed/api/user//albumid/) to IE9 or Chrome.
I have also tried to call the above URL via HttpWebRequest and set all no-cache headers, but it didnt solve the issue.
So, what is the difference between browsers request to the request done by the HttpWebRequest/API on this case?
Can anyone put me in the right direction?
Thanks

Just in case you haven't found out and might still be interested, I had the exact same problem (though in PHP) and it turns out that anonymous requests are delayed, while authorized requests are instant. Because your browser contained a cookie with your Google account, it counted as an authorized request and therefore was instantly updated. However, the request by the code was still anonymous.
The solution would be to make an HTTP POST to retrieve the feed, and authorize the request as described here.

Related

API authentification token

I have recently learnt about API and started using them for learning purpose.
I have tried the twitter API,but there is something I don't understand
Process of sending tweets with an API
Get your API token (need to tell a lot of informations and wait some time before it's validated)
Make http post request with the token to 'https://api.twitter.com/1.1/statuses/update
Tweet posted successfully
Process of sending tweets with your browser:
Create an account (don't need that much information, it's instant)
Login, write a tweet
When you click on submit, a http post request is sent (to the same url that above) and there is a Bearer token in the request header
Tweet posted successfully
So that leads to my question, why should I contact twitter to have an API token, if I can have one just by creating an account ?
How do twitter back-end know that the request is coming from a browser (normal use) or if it's coming from a third part app ?
The direct answer to your question is that the only approved way (inside of the Terms of Service) of sending Tweets programmatically is to use the official API.
There are a variety of ways in which websites and web services can detect browser automation or usage, and that's not really a question for a programming community like Stack Overflow.
What exactly are you trying to do, and why would you choose not to use the supported official API?

Branch.io: Caching Behaviour for Facebook Bot

We have used branch.io links in facebook posts and updated the target website after the facebook bot visited the website.
When we used the facebook sharing debugger to trigger the bot again, it turned out that the html code that bot received was still from the old version of the page.
We tested our site using curl on the target website url, and confirmed that the website was updated but facebook going via branch.io link didn't see the new content.
Also, when using the branch.io link with curl we didn't have any issue seeing the new content.
However, we did notice, that the results of the curl call differed quite a bit to what the facebook bot received from branch.io for the same url.
Branch.io did not only return old information to the bot but also rewrote some of the html (the latter is fine and expected).
The following is unclear to me:
How long will a page be cached by branch.io ?
Are (some) Cache-Control values respected ? I tried Cache-Control: no-cache but that didn't seem to influence the caching behaviour
Is there a way to force invalidation for a link ? I couldn't see any UI in the Branch.io dashboard.

Google API blocked my app ip address and returns CAPTCHA

My app uses Google API and it worked well for a long time but recently Google blocked the IP address of my server for about an hour and every response to the API was as follows: Our systems have detected unusual traffic from your computer network. This page checks to see if it's really you sending the requests, and not a robot... - they attached CAPTCHA form field as html.
My app is also an API so CAPTCHA can not be done because it is in json format (HTML in json cannot be rendered).
Only app users sends requests so I have a little control over it. Of course, I limit the number of requests per user, but it was not the case. Limits at google console are also fine.
I wonder how can I prevent this happening in the future? Is there any way I can ask them directly? Have you experienced this?

Browserless Authentication using the Web API

I am trying to authenticate a user inside a desktop application using the web api. I am not using a browser, I am using straight up GET and PUSH calls to the endpoints of the Spotify servers. Immediately I ran into some problems. It appears that upon the initial GET command to "accounts.spotify.com", the returned response includes HTML with a javascript function that runs and is responsible for dynamically generating HTML that you see on the initial login page. If you look at the Javascript function, it is clear that this is what is going on, however, you can also see this code is obfuscated and not meant to be used by us, the developers! (Link to Javascript code here for reference: Javascript function)
So my question is, while I can probably reverse engineer the code to get this working, would this be against the Spotify developer TOS?
Thanks!
Spotify's authentication happens through oauth, and a big part of user authentication as per the oauth rfc is where the user delegates permissions to your app to carry out API calls that affect their account, or return information about them. That's the web page you're seeing - it must be presented to your users so that they can delegate permissions so that Spotify can give your app an access token. It doesn't necessarily need to happen in a browser - it can happen in a web view inside your desktop application - but it does need to be loaded over https, and your application must not alter or reverse engineer the Spotify permissions delegations page.
As you correctly guessed, reverse engineering any Spotify APIs is against terms of service.
For more information on authorization on the Spotify platform, I'd recommend having a look at this guide.
Hope that helps! Please ping me if you have any more questions.
Hugh
Spotify Developer Support

Send Facebook friend request via iPhone app?

I'm trying to add a friend request feature to one of my apps. I've done quite a bit of research, and I've found out that I can't do that via the graph api. I've also looked into dialogs, and that isn't supported in FBConnect.
So my only option now would be to pop up a UIWebView and do it and format the url like this: http://www.facebook.com/dialog/friends/?id=FRIEND_ID&app_id=APP_ID&redirect_uri=REDIRECT_URI. That's not a problem, but if the user isn't logged in with Facebook on mobile safari, they will have to log in and that can get quite annoying.
Have any others dealt with this problem? Any good work-arounds?
Friend requests always need to be authenticated from the request sender side, hence the user will have to log in when using the friend request dialog if they are not already logged in.