From 0481dd05b00d3fda5c8323d822e7c43acff61824 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 2 Jul 2020 09:22:45 +0200 Subject: [PATCH] VerifyTweet now skips if twitter_api_auth is NULL --- server/verifyTweet.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/server/verifyTweet.php b/server/verifyTweet.php index bced5ff..669a83e 100644 --- a/server/verifyTweet.php +++ b/server/verifyTweet.php @@ -7,24 +7,27 @@ $tweetId = urlencode($_GET["id"]); $check = "\[Verifying my OpenPGP key: openpgp4fpr:$fingerprint\]"; -$ch = curl_init(); -curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $twitter_api_auth)); -curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_URL, "https://api.twitter.com/labs/2/tweets/$tweetId?tweet.fields=author_id,created_at,id,source,text"); -$result = curl_exec($ch); -curl_close($ch); -$data = json_decode($result, true); - $response = array(); $response["verified"] = false; $response["fingerprint"] = $fingerprint; $response["tweetId"] = $tweetId; $response["text"] = $data["data"]["text"]; -if (preg_match("/{$check}/i", $data["data"]["text"])) { - $response["verified"] = true; +if (!is_null($twitter_api_auth)) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $twitter_api_auth)); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_URL, "https://api.twitter.com/labs/2/tweets/$tweetId?tweet.fields=author_id,created_at,id,source,text"); + $result = curl_exec($ch); + curl_close($ch); + $data = json_decode($result, true); + + if (preg_match("/{$check}/i", $data["data"]["text"])) { + $response["verified"] = true; + } } + echo json_encode($response); ?>