user2200321
user2200321

Reputation: 445

Twitter OEmbed URL "No-Access-Control-Allow-Origin" from a regular server

I'm getting the following error when I try to get a Tweet's html based on an ID:

XMLHttpRequest cannot load https://api.twitter.com/1/statuses/oembed.json?id=484587947543781376. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://app-theysoundlike.rhcloud.com' is therefore not allowed access. 

As you can see, the origin is not localhost, it is on a regular server on Openshift. I'm using the following AngularJS code to make the request:

$http({
        url:'https://api.twitter.com/1/statuses/oembed.json?id='+data.id,
        method:"GET"
        }).success(function(data){
            $scope.tweetHTML = data.html;
            $scope.tweetAvailable = true;
        });
});

The data.id thing is not a problem, because the URL is being formed properly. The actual request is failing.

Upvotes: 1

Views: 1313

Answers (1)

strelok2010
strelok2010

Reputation: 1266

Try to use $http.jsonp with url

https://api.twitter.com/1/statuses/oembed.json?id={{YOUR_ID}}&callback=JSON_CALLBACK

Upvotes: 1

Related Questions