Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe an easy example for purge images in PHP #25

Closed
shakaran opened this issue Sep 5, 2017 · 6 comments
Closed

Describe an easy example for purge images in PHP #25

shakaran opened this issue Sep 5, 2017 · 6 comments

Comments

@shakaran
Copy link
Contributor

shakaran commented Sep 5, 2017

According to the documentation about purging images it shows an example for purge via Python, but it seems that there is no example in PHP or a method in this SDK library that implements this in a easy way

It is clear that must obey 3 conditions:

  1. Request to https://api.imgix.com/v2/image/purger
  2. Use the api key param
  3. Know the url to purge

In Curl is using like:

curl "https://api.imgix.com/v2/image/purger" \
  -u "$API_KEY:" \
  -d "url=$URL_TO_PURGE"

@haktansuren
Copy link

Simply replace {IMAGE_URL} and {API_KEY} accordingly @shakaran...

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.imgix.com/v2/image/purger");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"url\":\"{IMAGE_URL}\"}");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, {API_KEY});

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

@atrauzzi
Copy link

atrauzzi commented Jan 28, 2019

Hmm, I think the desire is to have a method in the SDK that can abstract all this request building away.

(I need this as well)

@jayeb
Copy link
Contributor

jayeb commented Jan 28, 2019

Hey folks,

Sorry for the radio silence in this thread. Adding "native" purging into our core SDK libraries is something we're planning to do in the near-to-medium future. We resisted this for a long time because we didn't think that it was worth "cluttering" the core libraries with something that was easily accomplishable in any language with a native HTTP request, but we've since come around and now agree with @atrauzzi: abstracting the messy, curly bits away from common imgix actions such as purging is exactly what this library should be doing.

If anyone wants to take a swing at this we'd happily accept a PR, but otherwise stay tuned 😄.

@jayeb jayeb closed this as completed Jan 28, 2019
@zipus
Copy link

zipus commented Aug 25, 2022

Sorry @jayeb, you mark this as completed, I don't see any commit or any docs about a sdk method, only the http default request.

@jayeb
Copy link
Contributor

jayeb commented Aug 25, 2022

@zipus I'm no longer working on this project, but I'll tag in @sherwinski here!

@sherwinski
Copy link
Contributor

Hey @zipus,
Nowadays we have a separate API for operations like purging, which we are planning to build out support for through a new set of SDKs. For right now we only have a JavaScript library for it, but if you're interested in a php-specific client let me know and I'll add a +1 to our item in the backlog for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants