mpratt / Embera

A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
MIT License
335 stars 59 forks source link

Custom Provider Parameters #76

Closed billtomczak closed 3 years ago

billtomczak commented 3 years ago

re: https://github.com/mpratt/Embera/blob/master/doc/07-advanced-usage.md#passing-custom-parameters-to-provider

This doesn't work for Facebook/Instagram access_tokens. $config['instagram_access_token'] will not be seen by the Instagram provider. If I pass $config['access_token'] then both Facebook and Instagram work fine.

It's unclear to me how best to fix this. access_token does need to be in $this->config but using instagram_access_token means it only appears in getParams() and the Instagram provider uses the legacy endpoint.

I'd be happy to create a PR with a proposed fix, but perhaps you would more quickly know the best way to deal with this.

mpratt commented 3 years ago

Hi @billtomczak Yes I'm planning on updating the library this weekend with new providers and addressing this issue! Thanks for the report!

billtomczak commented 3 years ago

Nice! TY!

mpratt commented 3 years ago

I'm pushing a new version that should work. I Just deleted the legacy endpoints for both facebook and Instagram. Can you guys test it out and tell if it solves the problem for you?

@hustlereq Facebook and Insta updated their oembed endpoint and behaviour. It now requires the use of an access_token parameter.

https://developers.facebook.com/docs/plugins/oembed https://developers.facebook.com/docs/instagram/oembed

How do you get the Access Token? You need to create an App on Insta/Facebook How do you integrate the access token with Embera?

This should work now.

$config = [
 'instagram_access_token' => 'yourtokenforinsta',
 'facebook_access_token' => 'yourtokenforfacebook'
];

$embera = new Embera($config);

Plz let me know if it works!

billtomczak commented 3 years ago

Thanks Michael - I can confirm this is fixed

billtomczak commented 3 years ago

@mpratt @hustlereq -- One thing we've been running into with the new Facebook/Instagram oembed is some pretty severe rate limiting. One of our customers is constantly getting refused requests on a site with lots of these links on their site.

Not a lot we can do about it, I suppose

billtomczak commented 3 years ago

@mpratt @hustlereq -- I was mistakenly using the Client Token which has severe limits. Using the App Secret provides much more generous limits that are not a problem for my customers.

One thing I'm having rouble with is the oembed_page endpoint. Facebook is returning a permission denied error. So far haven't found the magic incantation to use this endpoint.