Created
July 4, 2014 04:08
-
-
Save anonymous/0afb63e5553fabc25099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// First, let's get our Tinder ID | |
$ch = curl_init('https://api.gotinder.com/profile'); | |
curl_setopt_array($ch, array( | |
CURLOPT_CONNECTTIMEOUT => 2, | |
CURLOPT_HEADER => FALSE, | |
CURLOPT_HTTPHEADER => array( | |
'Content-Type: application/json; charset=utf-8', | |
'User-Agent: Tinder/4.0.3 (iPhone; iOS 7.0.4; Scale/2.00)', | |
'X-Auth-Token: XXX-XXX-XXX-XXX-XXX', | |
'Authorization: Token token="XXX-XXX-XXX-XXX-XXX"' | |
), | |
CURLOPT_PORT => 443, | |
CURLOPT_RETURNTRANSFER => TRUE | |
)); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
$json = json_decode($response, TRUE); | |
// Store our Tinder ID | |
$tinder_id = $json['_id']; | |
// Use this array to check matches from day 1 | |
$data = array(); | |
// Or, use this array to check matches within the last 15 minutes | |
$data = array( | |
'last_activity_date' => gmdate("c", (time() - 900)) // Current time minus 900 seconds (15 mins) | |
); | |
$ch = curl_init('https://api.gotinder.com/updates'); | |
curl_setopt_array($ch, array( | |
CURLOPT_CONNECTTIMEOUT => 2, | |
CURLOPT_HEADER => FALSE, | |
CURLOPT_HTTPHEADER => array( | |
'Content-Type: application/json; charset=utf-8', | |
'User-Agent: Tinder/4.0.3 (iPhone; iOS 7.0.4; Scale/2.00)', | |
'X-Auth-Token: XXX-XXX-XXX-XXX-XXX', | |
'Authorization: Token token="XXX-XXX-XXX-XXX-XXX"' | |
), | |
CURLOPT_POST => TRUE, | |
CURLOPT_POSTFIELDS => json_encode($data), | |
CURLOPT_PORT => 443, | |
CURLOPT_RETURNTRANSFER => TRUE | |
)); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
$json = json_decode($response, TRUE); | |
foreach ($json['matches'] as $match) | |
{ | |
// Assume we DON'T want to start a conversation at first | |
$start_convo = FALSE; | |
// If the conversation is blank, we will start a convo! | |
if (empty($match['messages'])) | |
{ | |
$start_convo = TRUE; | |
} | |
else | |
{ | |
// OK, so the conversation ISN'T blank, but we may not have wrote anything yet so let's check... | |
$conversation_made = FALSE; | |
foreach ($match['messages'] as $message) | |
{ | |
if ($message['from'] == $tinder_id) | |
{ | |
// A message has been sent FROM us so we HAVE made conversation | |
$conversation_made = TRUE; | |
} | |
} | |
if ( ! $conversation_made) | |
{ | |
// No conversation has been made by us, so let's talk! | |
$start_convo = TRUE; | |
} | |
} | |
// This is where we start the convo | |
if ($start_convo) | |
{ | |
$ch = curl_init('https://api.gotinder.com/user/matches/'.$match['_id']); | |
curl_setopt_array($ch, array( | |
CURLOPT_CONNECTTIMEOUT => 2, | |
CURLOPT_HEADER => FALSE, | |
CURLOPT_HTTPHEADER => array( | |
'Content-Type: application/json; charset=utf-8', | |
'User-Agent: Tinder/4.0.3 (iPhone; iOS 7.0.4; Scale/2.00)', | |
'X-Auth-Token: XXX-XXX-XXX-XXX-XXX', | |
'Authorization: Token token="XXX-XXX-XXX-XXX-XXX"' | |
), | |
CURLOPT_POST => TRUE, | |
CURLOPT_POSTFIELDS => json_encode(array( | |
'message' => 'ASL?', | |
)), | |
CURLOPT_PORT => 443, | |
CURLOPT_RETURNTRANSFER => TRUE | |
)); | |
curl_exec($ch); | |
} | |
// Finally we'll sleep for 10 seconds before moving on to the next match... | |
sleep(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment