Skip to content

Instantly share code, notes, and snippets.

@atsu666
Last active September 20, 2016 02:38
Show Gist options
  • Save atsu666/388807d0ba1ccf08c160 to your computer and use it in GitHub Desktop.
Save atsu666/388807d0ba1ccf08c160 to your computer and use it in GitHub Desktop.
a-blog cms : facebook debugger
<?php
/**
* php/ACMS/User/POST/FBDebugger.php
*
* テンプレート上では、標準のPOSTモジュールと同様に、
* <input type="submit" name="ACMS_POST_FBDebugger" value="Clear FB Cache"> で呼び出されます。
*/
class ACMS_User_POST_FBDebugger extends ACMS_POST
{
protected $endpoint = "https://graph.facebook.com/?scrape=true&id=%s";
/**
* run
*
* @return ACMS_POST
*/
public function post()
{
if ( !sessionWithAdministration() ) return false;
$url = sprintf($this->endpoint, rawurlencode(HTTP_REQUEST_URL));
$this->request($url);
return $this->Post;
}
/**
* post request
*
* @param string $url
* @return void
*/
protected function request($url)
{
include_once 'HTTP/Request.php';
$req = new HTTP_Request($url);
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addHeader('Content-Type', 'application/x-www-form-urlencoded');
if ( $req->sendRequest() ) {
$body = $req->getResponseBody();
} else {
userErrorLog('ACMS Warning: Failed clear fb cache.');
die503('Failed clear fb cache.');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment