NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php
/**
* Created by PhpStorm.
* User: aliOS
* Date: 4.06.2019
* Time: 01:06
*/

class swarmAuth
{
private $_useragent = 'com.foursquare.batman.ios.phone:20190529.1213.40:20190522:iOS 12.3.1:iPhone9,4';
private $_proxy = null;
private $_image = null;
private $_result = 0;
private $_ll = null;
public $_tokenlar = array();
private $onlyToken = false;
private $client_id = 'UJXJTUHR42CKGO54KXQWGUZJL3OJKMKMVHGJ1SWIOC5TRKAC';
private $client_secret = 'IGDLQ4SE0CXBOY0YULKCVAIGVLDHIYNS4JWHIPMUJ3SZ42PW';
private $wsid = '6402239D-1951-49E6-92BA-DF3F9DA11103';
private $_v = '20190522';
private $csid = '3';
private $xs_fs_consumer = '2';
private $_m = 'foursquare';
private $access_token = null;
private $batteryStrenght = null;
private $hesaplar = array();
private function generateUserSignature($mail)
{
$header = json_encode(['alg' => 'HS256', 'typ' => 'JWT']);
$payload = json_encode(['exp' => time()+3600, 'email' => $mail]);
$base64UrlHeader = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($header));
$base64UrlPayload = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($payload));
$signature = hash_hmac('sha256', $base64UrlHeader . "." . $base64UrlPayload, 'GKCDBUSZVBLYXQYNRIZI3DHFU1ZAA2MC', true);
$base64UrlSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($signature));
$jwt = $base64UrlHeader . "." . $base64UrlPayload . "." . $base64UrlSignature;
return $jwt;
}

public function signup($_PARAMS = NULL) {
$hesaplar = array();
if (!empty($_PARAMS)) {
$veriler = $_PARAMS;
$params = array();
foreach ($veriler as $veri) {
$signature = $this->generateUserSignature($veri['email']);
$fields = array(
'm' => $this->_m,
'csid' => $this->csid,
'lastName' => $veri['lastName'],
'firstName' => $veri['firstName'],
'birthDate' => $veri['birthDate'],
'marketingEmailOptIn' => '0',
'wsid' => $this->wsid,
'hourFormat' => '24',
'birthYear' => $veri['birthYear'],
'password' => $veri['password'],
'foreignConsent' => 'notrequired',
'signupSource' => 'iphone-email',
'signature' => $signature,
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'birthMonth' => $veri['birthMonth'],
'email' => $veri['email'],
'gender' => 'female',
'v' => $this->_v
);

$fields_string = null;

foreach ($fields as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
rtrim($fields_string, '&');

$header = array(
"Accept: */*",
"Accept-Language: tr-TR-TR",
"Content-Type: application/x-www-form-urlencoded",
"X-Fs-Consumer: ".$this->xs_fs_consumer
);

$options = array(
CURLOPT_POST => count($fields),
CURLOPT_POSTFIELDS => $fields_string,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_USERAGENT => $this->_useragent,
CURLOPT_ENCODING => 'br, gzip, deflate'
);
//if($this->_proxy) $options[] = array('CURLOPT_PROXY' => $this->_proxy);

$params[] = array(
'url' => "https://api.foursquare.com/v2/users/add",
'options' => $options
);
}

//echo json_encode($this->hesaplar);
} else {
throw new Exception('Hata: signup() - İşlem yaptırabilmeniz için {_PARAMS} tanımlamalısınız.');
}

$multiCURL = new RollingCurlRollingCurl();
foreach ($params as $param) {
$request = new RollingCurlRequest($param['url'], 'POST');
$request->setOptions($param['options']);
$multiCURL->add($request);
}

$this->_result = 0;
$multiCURL
->setCallback(function (RollingCurlRequest $request, RollingCurlRollingCurl $rollingCurl) {

$result = $request->getResponseText();
//echo $result;
if (is_string($result)) {
$result = json_decode($result);
if (is_object($result)) {
if ($result->meta->code == 200){
//echo $result->response->access_token.'<br>';
$this->hesaplar[] = array(
'access_token' => $result->response->access_token
);
$this->_tokenlar[] = array("oauth_token" => $result->response->access_token);
$this->_result++;
}
}
}
})
->setSimultaneousLimit(100)
->execute();

$result = array(
'success' => $this->_result,
'errors' => NULL
);

//print_r($this->_tokenlar);
echo json_encode($this->hesaplar, JSON_PRETTY_PRINT);
if(!empty($this->_tokenlar)) $this->updatePhoto($this->_tokenlar);
return json_decode(json_encode($result));
}

public function updatePhoto(){
//$tokenlar = array();
if (!empty($this->_tokenlar)) {
//echo json_encode($this->_tokenlar);
$veriler = json_decode(json_encode($this->_tokenlar));
$params = array();
foreach ($veriler as $veri) {

$token = $veri->oauth_token;
$metada = $this->photo($this->_image);

$fields = array(
'hourFormat' => '24',
'm' => $this->_m,
'photoMetadata' => $metada,
'csid' => $this->csid,
'oauth_token' => $token,
'photo' => new CURLFile($this->_image,'image/jpeg','photo.jpg'),
'v' => $this->_v,
);

$hesaplar[] = $fields;

$header = array(
"Accept: */*",
"Accept-Language: tr-TR-TR",
"Content-Type: multipart/form-data",
"X-Fs-Consumer: ".$this->xs_fs_consumer
);

$options = array(
CURLOPT_POST => count($fields),
CURLOPT_POSTFIELDS => $fields,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_USERAGENT => $this->_useragent,
//CURLOPT_PROXY => $this->_proxy,
CURLOPT_ENCODING => 'br, gzip, deflate'
);

$params[] = array(
'url' => "https://api.foursquare.com/v2/users/self/update",
'options' => $options
);
}
//echo json_encode($tokenlar);
} else {
//echo 'PARAM BOŞŞŞ<br>';
throw new Exception('Hata: updatePhoto() - İşlem yaptırabilmeniz için {_PARAMS} tanımlamalısınız.');
}

$multiCURL = new RollingCurlRollingCurl();
foreach ($params as $param) {
$request = new RollingCurlRequest($param['url'], 'POST');
$request->setOptions($param['options']);
$multiCURL->add($request);
}

$this->_result = 0;
$multiCURL
->setCallback(function (RollingCurlRequest $request, RollingCurlRollingCurl $rollingCurl) {

$result = $request->getResponseText();
//echo $result;
if (is_string($result)) {
$result = json_decode($result);
if (is_object($result)) {
if ($result->meta->code == 200){
$this->_result++;
}
}
}
})
->setSimultaneousLimit(100)
->execute();

$result = array(
'success' => $this->_result,
'errors' => NULL
);
return json_decode(json_encode($result));
}

protected function _cURL($params)
{
$ch = curl_init();

$options = array(
CURLOPT_URL => $params['url'],
CURLOPT_HEADER => FALSE,
CURLOPT_USERAGENT => $this->_useragent,
CURLOPT_FOLLOWLOCATION => FALSE,
CURLOPT_RETURNTRANSFER => TRUE
);
if (is_array($params['options'])) {
foreach ($params['options'] as $option => $value) {
$options[$option] = $value;
}
}
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);

return json_decode($response);
}

protected function _multipleMultiCurl($params)
{

$result = array();
$multiCurl = array();
$selco = curl_multi_init();
$query = 0;
for ($i = 0; $i <= (count($params) - 1); $i++) {
foreach ($params[$i] as $param) {
if (is_array($param)) {
$multiCurl[$query] = curl_init();

$options = array(
CURLOPT_URL => $param['url'],
CURLOPT_HEADER => FALSE,
CURLOPT_USERAGENT => $this->_useragent,
CURLOPT_FOLLOWLOCATION => FALSE,
CURLOPT_RETURNTRANSFER => TRUE
);

if (isset($param['options']) && is_array($param['options'])) {
foreach ($param['options'] as $option => $value) {
$options[$option] = $value;
}
}
curl_setopt_array($multiCurl[$query], $options);
curl_multi_add_handle($selco, $multiCurl[$query]);

$query++;
}
}
}

$running = NULL;
do {

curl_multi_exec($selco, $running);

} while ($running > 0);

foreach ($multiCurl as $key => $value) {
$result[$key] = curl_multi_getcontent($value);
curl_multi_remove_handle($selco, $value);
}
curl_multi_close($selco);

return str_replace(array("n", "t", "r"), NULL, $result);
}

protected function getCurlValue($filename)
{
$image = getimagesize($filename);

// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
// See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
return curl_file_create($filename, $image['mime'], $filename);
}

// Use the old style if using an older version of PHP
$value = "@{$filename};filename=" . $filename;
if ($image['mime']) {
$value .= ';type=' . $image['mime'];
}

return $value;
}

protected function photo($image){
$data = getimagesize($image);
$width = $data[0];
$height = $data[1];
$json = array(
"{TIFF}" => array(
"Orientation" => 1,
"ResolutionUnit" => 2,
"XResolution" => 72,
"YResolution" => 72
),
"{Exif}" => array(
"ColorSpace" => 1,
"PixelXDimension" => $width,
"ExifVersion" => [2,2,1],
"FlashPixVersion" => [1,0],
"PixelYDimension" => $height,
"SceneCaptureType" => 0,
"ComponentsConfiguration" => [1,2,3,0]
),
"{JFIF}" => array(
"XDensity" => 72,
"YDensity" => 72,
"JFIFVersion" => [1,0,1],
"DensityUnit" => 0
),
"ProfileName" => "sRGB IEC61966-2.1",
"PixelHeight" => $height,
"DPIWidth" => 72,
"ColorModel" => "RGB",
"Depth" => 8,
"PixelWidth" => $width,
"Orientation" => 1,
"DPIHeight" => 72
);

//echo json_encode($json);
return json_encode($json);
}

public function setProxy($proxy)
{
$this->_proxy = $proxy;
}

public function setImage($image){
$this->_image = $image;
}

public function setCoor($coor){
$this->_ll = $coor;
}

public function batteryStrenght(){
return '0.'.rand(10,99).'0000';
}

public function setAccessToken($access_token){
$this->access_token = $access_token;
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.