PHP code example of henshall / php-tinder-api

1. Go to this page and download the library: Download henshall/php-tinder-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

henshall / php-tinder-api example snippets


use Henshall\TinderApi;
use Henshall\TinderMockApi;
use Henshall\TinderApiInterface;

$myTinderPhoneNumber = "1112223456"; // no spaces
$tinderApi = new TinderApi;
$result = $tinderApi->requestCode($myTinderPhoneNumber);

$myTinderPhoneNumber = "1112223456"; // no spaces
$tinderApi = new TinderApi;
$result = $tinderApi->validateCode($myTinderPhoneNumber, "123456");
// Grab the Refresh Token
$refresh_token = $result->data["refresh_token"];

$tinderApi = new TinderApi;
$result = $tinderApi->getTokenFromRefreshToken($refresh_token);
// Grab the Tinder API Token
$tinder_token = $result["api_token"];

$tinderApi = new TinderApi;
$result = $tinderApi->getProfile($tinder_token);

$tinderApi = new TinderApi;
$result = $tinderApi->getMetadata($tinder_token);

$tinderApi = new TinderApi;
$result = $tinderApi->getRecommendations($tinder_token);

$tinderApi = new TinderApi;
$result = $tinderApi->like($tinder_token, $id);

$tinderApi = new TinderApi;
$result = $tinderApi->pass($tinder_token, $id);

try {
    // Asign Variables
    $tinderApi = new TinderApi;
    $token = "1234567890qwerty";
    $position = ['lat' => "43.47876072885527", 'lon' => "-110.76437540803676"];
    // Try To Update Location
    echo "Attempting to update user Swipe Location\n";
    $update = $tinderApi->ping($token, $position);
    if (isset($update["status"]) && $update["status"] == 200) {
        echo "Location Change Successful! \n";
        return $update;
    } else {
        echo "Location Change Failed \n";
        return false; 
    }
} catch (\Exception $e) {
    echo "Location Change Failed \n";
    return false;
}

$tinderApi = new TinderMockApi;
$result = $tinderApi->getProfile($tinder_token);


class Swiper 
{
    private $tinderApi;
    
    public function __construct(\App\Tinder\TinderApiInterface $tinderApi)
    {
        echo "SWIPER CREATED \n";
        $this->tinderApi = $tinderApi;
    }
    
    public function swipe($token, $id, $swipe_type){   
        if ($swipe_type == "like") {
            try {
                echo "swiping right \n";
                $response = $this->tinderApi->like($token, $id);
                
            } catch (\Exception $e) {
                echo "Failed to Swipe Right \n";
                return false;
            }
        } elseif ($swipe_type == "pass") {
            try {
                echo "swiping left \n";
                $response = $this->tinderApi->pass($token, $id);
            } catch (\Exception $e) {
                echo "Failed to Swipe Right \n";
                return false;
            }
        } else {
            echo "swipe_type is wrong - you should never see this \n";
            return null;
        }
        return $response;        
    }
}

$swiper = new Swiper(new TinderApi);

$swiper = new Swiper(new TinderMockApi);
bash
composer