php - instagram api Real-time challenge get code 200 but void data -
my goal create subscription of application , info tag love
class indexcontroller extends app_controller_default
{ public function indexaction() { $data = $this->_getsubscriptiontag(); zend_debug::dump($data); }
public function realtimecallbackaction() { $this->_helper->layout->disablelayout(); $this->_helper->viewrenderer->setnorender(true); $allparams = $this->_getallparams(); $datafile = root_dir.'/data.txt'; file_put_contents($datafile, implode(',',$_get).implode(',',array_keys($_get))); if(isset($_get['hub_challenge'])){ $challenge = $_get['hub_challenge']; $file = root_dir.'/json.txt'; $json = $this->_challenge($challenge); file_put_contents($file, $json); } $request = $this->getrequest(); if($request->ispost()){ $filepostdata = root_dir.'/postdata.txt'; $postdata = file_get_contents("php://input"); file_put_contents($filepostdata, $postdata, file_append | lock_ex); } } protected function _getsubscriptiontag($verifytoken='') { $config = array( 'adapter' => 'zend_http_client_adapter_curl', 'curloptions' => array(curlopt_followlocation => true), ); $uri = 'https://api.instagram.com/v1/subscriptions/'; $request = $this->getrequest(); $callbackurl= $request->getscheme().'://'.$request->gethttphost().$request->getbaseurl().'/index/realtimecallback'; $client = new zend_http_client(); $client->seturi($uri); $client->setconfig($config); $client->setmethod(zend_http_client::post); $client->setparameterpost('client_id', 'my_id'); $client->setparameterpost('client_secret', 'my_secret'); $client->setparameterpost('object', 'tag'); $client->setparameterpost('aspect', 'media'); $client->setparameterpost('object_id', 'love'); $client->setparameterpost('verify_token', $verifytoken); $client->setparameterpost('callback_url', $callbackurl); $response = $client->request(); $httpcode = $response->getstatus(); $httpheaders = $response->getheaders(); $httpbody = $response->getbody(); $data = array(); try{ $data = zend_json_decoder::decode($httpbody,zend_json::type_array); } catch(exception $e){ $data['error_type'] = 'malformed json'; $data['error_message'] = $e->getmessage(); } var_dump($client->getlastrequest()); homecoming $data; } protected function _challenge($challenge) { $config = array( 'adapter' => 'zend_http_client_adapter_curl', 'curloptions' => array(curlopt_followlocation => true), ); $uri = 'https://api.instagram.com/v1/subscriptions/'; $client = new zend_http_client(); $client->seturi($uri); $client->setconfig($config); $client->setparameterget('challenge', $challenge); $client->setparameterget('client_id', 'my_id'); $client->setparameterget('client_secret', 'my_secret'); $response = $client->request(); $httpcode = $response->getstatus(); $httpheaders = $response->getheaders(); $httpbody = $response->getbody(); homecoming $httpbody; }
}
in json.txt file {"meta":{"code":200},"data":[]} , if request https://api.instagram.com/v1/subscriptions?client_secret=client-secret&client_id=client-id same don't know way turn :( can help me, please ?
i tried $client->setparameterget('verify_token', $challenge); doesn't work :(
:)
public function realtimeaction() { $file = root_dir.'/json.txt'; $data = $this->_getsubscriptiontag(); $request = $this->getrequest(); if($request->ispost()){ $filepostdata = root_dir.'/postdata.txt'; $postdata = file_get_contents("php://input"); file_put_contents($filepostdata, $postdata, file_append | lock_ex); } zend_debug::dump($data); } public function realtimecallbackaction() { $this->_helper->layout->disablelayout(); $this->_helper->viewrenderer->setnorender(true); if(isset($_get['hub_challenge'])){ $challenge = $_get['hub_challenge']; echo $challenge; exit; }
}
very http://thegregthompson.com/instagram-real-time-api-php/
php zend-framework
No comments:
Post a Comment