问题
When I request the data using yammer API sometimes I get hte data while sometimes I get error saying
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.yammer.com/api/v1/topics/4990456.json?&_=1409122520954. This can be fixed by moving the resource to the same domain or enabling CORS.
When I try URL : https://www.yammer.com/api/v1/topics/4990456.json
to get messages for topic number 4990456, I get the above mentioned error in console log.
Similarly, when I try URL : https://www.yammer.com/api/v1/messages/about_topic/
, I again get the above mentioned error in console log.
However, from the same page, same domain, same code, if I request https://api.yammer.com/api/v1/messages/my_feed.json
, I get response back.
Can someone please explain this discrepancy ? Is this the correct way to get the messages in a topic ?
回答1:
I think the answer is in the domain name.
www.yammer.com and api.yammer.com are treated as two different domains!
I haven't tried it but I think it is a pretty safe guess that api.yammer.com will work for your first two requests too.
来源:https://stackoverflow.com/questions/25520775/yammer-cors-error-appears-only-for-some-api-calls