File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,16 @@ protected function getTokenUrl()
46
46
*/
47
47
protected function getUserByToken ($ token )
48
48
{
49
+ $ endpoint = '/users/self ' ;
50
+ $ query = [
51
+ 'access_token ' => $ token ,
52
+ ];
53
+ $ signature = $ this ->generateSignature ($ endpoint , $ query );
54
+
55
+ $ query ['sig ' ] = $ signature ;
49
56
$ response = $ this ->getHttpClient ()->get (
50
- 'https://api.instagram.com/v1/users/self?access_token= ' .$ token , [
57
+ 'https://api.instagram.com/v1/users/self ' , [
58
+ 'query ' => $ query ,
51
59
'headers ' => [
52
60
'Accept ' => 'application/json ' ,
53
61
],
@@ -91,4 +99,19 @@ protected function getTokenFields($code)
91
99
'grant_type ' => 'authorization_code ' ,
92
100
]);
93
101
}
102
+
103
+ /**
104
+ * Allows compatibility for signed API requests.
105
+ */
106
+ protected function generateSignature ($ endpoint , array $ params )
107
+ {
108
+ $ sig = $ endpoint ;
109
+ ksort ($ params );
110
+ foreach ($ params as $ key => $ val ) {
111
+ $ sig .= "| $ key= $ val " ;
112
+ }
113
+ $ signing_key = $ this ->clientSecret ;
114
+
115
+ return hash_hmac ('sha256 ' , $ sig , $ signing_key , false );
116
+ }
94
117
}
You can’t perform that action at this time.
0 commit comments