5353 $ client ->setRedirectUrl ($ _SESSION ['redirect_url ' ]);
5454 // retrieve access token using code provided by LinkedIn
5555 $ accessToken = $ client ->getAccessToken ($ _GET ['code ' ]);
56- echo 'Access token: ' ;
56+ h1 ( 'Access token ' ) ;
5757 pp ($ accessToken ); // print the access token content
58- echo 'Profile: ' ;
58+ h1 ( 'Profile ' ) ;
5959 // perform api call to get profile information
6060 $ profile = $ client ->get (
6161 'people/~:(id,email-address,first-name,last-name) '
8383 // https://www.linkedin.com/company/devtestco
8484 $ companyId = '2414183 ' ;
8585
86+ h1 ('Company information ' );
87+ $ companyInfo = $ client ->get ('companies/ ' . $ companyId . ':(id,name,num-followers,description) ' );
88+ pp ($ companyInfo );
89+
90+ h1 ('Sharing on company page ' );
8691 $ companyShare = $ client ->post (
8792 'companies/ ' . $ companyId . '/shares ' ,
8893 [
104109 ]
105110 );
106111 pp ($ companyShare );
112+
107113
108114 /*
109115 // Returns {"serviceErrorCode":100,"message":"Not enough permissions to access media resource","status":403}
135141 echo '<a href="/">Start over</a> ' ;
136142} else {
137143 // define desired list of scopes
138- $ scopes = Scope::getValues ();
144+ $ scopes = [
145+ Scope::READ_BASIC_PROFILE ,
146+ Scope::READ_EMAIL_ADDRESS ,
147+ Scope::MANAGE_COMPANY ,
148+ Scope::SHARING ,
149+ ];
139150 $ loginUrl = $ client ->getLoginUrl ($ scopes ); // get url on LinkedIn to start linking
140151 $ _SESSION ['state ' ] = $ client ->getState (); // save state for future validation
141152 $ _SESSION ['redirect_url ' ] = $ client ->getRedirectUrl (); // save redirect url for future validation
@@ -151,3 +162,12 @@ function pp($anything)
151162{
152163 echo '<pre> ' . print_r ($ anything , true ) . '</pre> ' ;
153164}
165+
166+ /**
167+ * Add header
168+ *
169+ * @param string $h
170+ */
171+ function h1 ($ h ) {
172+ echo '<h1> ' . $ h . '</h1> ' ;
173+ }
0 commit comments