Skip to content

Instantly share code, notes, and snippets.

@Montoya
Last active May 3, 2024 18:39
Show Gist options
  • Save Montoya/77c95bfc8f737f5f6a5b39bb494e96d2 to your computer and use it in GitHub Desktop.
Save Montoya/77c95bfc8f737f5f6a5b39bb494e96d2 to your computer and use it in GitHub Desktop.
<?php
header('Content-Type: application/json; charset=utf-8');
header("Access-Control-Allow-Origin:*");
function isLikeAddress($address) {
if (!preg_match('/^(0x)?[0-9a-f]{40}$/i',$address)) {
// Check if it has the basic requirements of an address
return false;
}
else {
return true;
}
}
if(isset($_GET['address'])) {
if(!isLikeAddress($_GET['address'])) {
exit('{"error":"invalid address passed"}');
}
}
else {
exit('{"error":"not set"}');
}
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.neynar.com/v2/farcaster/user/bulk-by-address?addresses=".$_GET['address'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"accept: application/json",
"api_key: NEYNAR_API_DOCS"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment