This API gets the profile of the User.
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 Getprofile extends Container { function __construct(){ parent::__construct(); // Get Profile Details Url $this->profileUrl = "/sms/2.0/ui/subscriber/get/details"; $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 getprofile(){ $url = $this->domain . $this->profileUrl . "/" . $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 Getprofile(); $resp = $r->getprofile(); print_r($resp); |
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 |
{ "UId":"5677c2c364c742e50779c625", "id":198, "username":"unscb@test.com", "dob":"","fname":"Unscb", "lname":"Test", "gender":"m", "reg_device":"2", "status":5, "is_blocked":false, "reg_time":1442325419000, "sub_device":5, "sub_time":1450692667324, "sub_cancel_time":1464430287728, "sub_revenue":2624, "view_data": { "first_seen_ts":1442382455000, "last_seen_ts":1482486881000, "num_view":162, "viewtime":11313, "device_view_count": { "roku":1, "androidphone":0, "androidtab":0, "iphone":0, "ipad":0, "web":11312, "samsungtv":0, "appletv":0 }, "view_avg":69.0 },"indexes": { "reg2view":0, "recency":10, "relevency":0.0, "view_active":464, "sub_engagement":46.4, "avg_view":0.47, "view_engagement":0.19, "days_registered":475, "reg2sub":96, "days_subscribed":159, "view_per_day":0.35, "qoeindex":5 }, "street":"3080 Olcott Street", "city":"San Josh", "state":"CA", "phone":"", "country":"US", "zip":"95054" } |