This API is used to whether the user exists. basically this API verifies for existing Email ID or Subscriber ID.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
/** * JunctionTV Subscriber Management with access token * */ class Container { function __construct(){ // Domain $this->domain = "http://__JTV__HOST__"; $this->token = ""; $this->username = "helloworld@test.com"; } function getAccessToken(){ // set up request for access token $data = array(); $client_id = 'jtv'; // Client ID $client_secret = '***********'; //Client Secret $auth_string = "{$client_id}:{$client_secret}"; $request = "https://cloud.junctiontv.net/ums/2.0/oauth/"; $ch = curl_init($request); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_USERPWD => $auth_string, CURLOPT_HTTPHEADER => array( 'Content-type: application/x-www-form-urlencoded' ), CURLOPT_POSTFIELDS => $data )); $response = curl_exec($ch); // Check for errors if (!curl_errno($ch)) { $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); }else{ die(curl_error($ch)); } curl_close($ch); if(isset($httpcode) && $httpcode == 200){ return $response; }else{ return false; } } } class Checkuser extends Container { function __construct(){ parent::__construct(); // Check User Exist Url $this->checkUrl = "/sms/2.0/ui/subscriber/isvalid"; $tok = $this->getAccessToken(); if($tok){ $tok = json_decode($tok); if(isset($tok->access_token)){ $this->token = $tok->access_token; }else{ die("Unauthorize"); } }else{ die("Unauthorize"); } } function checkuser(){ $url = $this->domain . $this->checkUrl . "/" . $this->username; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array( "Authorization: Bearer " . $this->token, ) )); //execute $result = curl_exec($ch); // Check for errors if (!curl_errno($ch)) { $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); }else{ die(curl_error($ch)); } //close connection curl_close($ch); if(isset($httpcode) && $httpcode == 200){ return $result; }else{ return "HTTP Status Code ". $httpcode; } } } $r = new Checkuser(); $resp = $r->checkuser(); print_r($resp); |
1 2 3 4 5 6 |
{ "code":0, "result":"success", "status":"success", "message":"" } |
1 2 3 4 5 6 |
{ "code":1001, "result":"failure", "status":"failure", "message":"Email ID is already registered." } |