function twitter_verify_asset($verifications_json) { $tweet_content = get_tweet(get_tweet_id($verifications_json)); $expected_content = get_expected_text($verifications_json); $check = $tweet_content == $expected_content ? TRUE : FALSE; // Eyal, I think we should log the following msg $msg = $check ? 'Asset is verified' : 'Asset verification failed. Expected [' . $expected_content . '] but got [' . $tweet_content . ']'; // echo "<br/>".$msg; return $check; }
function github_verify_asset($verifications_json) { $pid = get_pid($verifications_json); if (!$pid) { return false; } // $gist_content = parse_gist(get_gist_no_oauth($pid)); $gist_content = parse_gist(get_gist_with_oauth($pid)); $expected_content = get_expected_text($verifications_json); $check = $gist_content == $expected_content ? TRUE : FALSE; // Eyal, I think we should log the following msg // $msg = ($check ? 'Asset is verified': 'Asset verification failed. Expected ['.$expected_content.'] but got ['.$gist_content.']'); // echo "<br/>msg: [".$msg."]"; return $check; }
function fb_verify_asset_with_token($verifications_json, $token) { $uidx = get_uid($verifications_json); $pidx = get_pid($verifications_json); if (!$pidx || !$uidx) { return false; } $postx = get_post_with_token($uidx, $pidx, $token); $post_contentx = parse_post($postx); $expected_contentx = get_expected_text($verifications_json); $check = $post_contentx == $expected_contentx ? TRUE : FALSE; // Eyal, I think we should log the following msg if (!$check) { $msg = $check ? 'Asset is verified' : 'Asset verification failed. Expected [' . $expected_contentx . '] but got [' . $post_contentx . ']'; echo "<br/>msg: [" . $msg . "]"; } return $check; }
// $accesstoken = fetch_access_token(TOKEN_FILE); $post = get_post($uid, $pid); $ct = json_decode($post, TRUE)['created_time']; $er = json_decode($post, TRUE)['error']['message']; // $user_post = get_post('100010281887017','486051034905643'); // TESTS // $var_test = ()? PASS:FAIL; $verified_test = fb_verify_asset($verified_json) == 1 ? PASS : FAIL; $unverified_test = fb_verify_asset($unverified_json) != 1 ? PASS : FAIL; $fake_networks_test = fb_verify_asset($fake_networks_json) != 1 ? PASS : FAIL; $another_user_test = fb_verify_asset($user2_json) == 1 ? PASS : FAIL; $third_user_test = fb_verify_asset($user3_json) == 1 ? PASS : FAIL; $another_token_test = fb_verify_asset_with_token($verified_json, FB_APP_TOKEN_2) == 1 ? PASS : FAIL; $pid_test = $pid == 486035954907151.0 ? PASS : FAIL; $uid_test = $uid == 1232952150 ? PASS : FAIL; $expected_text = preg_match("/LJEC6Q2h9JKNvZqEC87TbEXvxm4br1uivb2QX/", get_expected_text($verified_json)) ? PASS : FAIL; // 2015-10-06T08:28:06+0000 $getpost_test = strlen($ct) == 24 ? PASS : FAIL; $content_test = preg_match("/LJEC6Q2h9JKNvZqEC87TbEXvxm4br1uivb2QX/", parse_post($post)) ? PASS : FAIL; $error_test = preg_match("/Error validating access token/", $er) ? FAIL : PASS; // OUTPUT echo "<br/>verified_test: [" . $verified_test . "]"; echo "<br/>unverified_test: [" . $unverified_test . "]"; echo "<br/>fake_networks_test: [" . $fake_networks_test . "]"; echo "<br/>another_user_test: [" . $another_user_test . "]"; echo "<br/>third_user_test: [" . $third_user_test . "]"; echo "<br/>another_token_test: [" . $another_token_test . "]"; echo "<hr/>"; echo "<br/>post id from json: [" . $pid_test . "]"; echo "<br/>user id from json: [" . $uid_test . "]"; // echo "<br/>access token from file: [".$accesstoken_test."]";