Example #1
0
 /**
  * Prepare basic options for curl adapter
  *
  * @param int|float|bool $timeout in seconds
  *
  * @return Enterprise_Search_Model_Client_Solr
  */
 protected function _setBasicAdapterOptions($timeout)
 {
     if ($timeout <= 0) {
         $timeout = $this->_defaultTimeout;
     }
     $optionsList = array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => (int) $timeout);
     if (strlen($this->getUserLogin()) && strlen($this->getPassword())) {
         $optionsList[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
         $optionsList[CURLOPT_USERPWD] = $this->getUserLogin() . ':' . $this->getPassword();
     }
     $this->_curlAdapter->setOptions($optionsList);
     return $this;
 }
Example #2
0
 public function indexAction()
 {
     /*$http = new Varien_Http_Adapter_Curl();
     		$cookie = 'cookie.txt';
     		$account = '*****@*****.**'; 
     		$password= '******';
     		$appIdPrefix = "88X6EP4WFV";
     		
     		$config = array('timeout' => 3000,'verifypeer' => FALSE,'verifyhost' => FALSE);
     		
     		$naAppCodeName = 'Mozilla';
     		$naAppName = 'Netscape';
     		$naAppVersion = '5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36';
     		
     		
     		$options = array(CURLOPT_USERAGENT => "$naAppCodeName/$naAppVersion",
     						CURLOPT_COOKIEJAR => realpath($cookie),
     						CURLOPT_COOKIEFILE => realpath($cookie)
     					);
         	$http->setConfig($config);
     		$http->setOptions($options);
     		
     		
     		//get link login
     		$url = 'https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/wa/directToSignIn?localang=en_US';
     		$http->write(Zend_Http_Client::GET, $url, '1.1');
     		$content = $http->read();
     		
     		$regex_pattern =  "/id=\"signIn\" name=\"appleConnectForm\" action=\"(.*?)\">/";
     		preg_match($regex_pattern, $content, $match);
     		
     		$url = 'https://appleid.apple.com'.$match[1];
     		
     		$regex_pattern =  "/id=\"fdcBrowserDataId\" type=\"hidden\" name=\"(.*?)\"/";
     		preg_match($regex_pattern, $content, $match);
     		$fdcBrowserDataId = $match[1];
     		
     		$regex_pattern =  "/id=\"actionChosen\" type=\"hidden\" name=\"(.*?)\"/";
     		preg_match($regex_pattern, $content, $match);
     		$actionChosen = $match[1];
     		
     		$regex_pattern =  "/name=\"wosid\" value=\"(.*?)\"/";
     		preg_match($regex_pattern, $content, $match);
     		$wosid = $match[1];
     		
     		$naProductSub = '20030107';
     		$naBrowserLanguage = 'undefined';
     		$naCookieEnabled = 'true';
     		$navigatorOscpu = $naCpuClass = ''; //undefined
     		$naOnLine = 'true';
     		$naPlatform = 'Win32';
     		$naSystemLanguage = 'undefined';
     		$naLanguage = 'en-US';
     		$documentDefaultCharset = 'ISO-8859-1';
     		$documentDomain = 'appleid.apple.com';
     		$screenDeviceXDPI = 'undefined';
     		$screenDeviceYDPI = 'undefined';
     		$screenFontSmoothingEnabled = 'undefined';
     		$screenUpdateInterval = 'undefined';
     		$timeZoneOffset = date('Z')/3600;
     		$date = '6/7/2005 9:33:44 PM';
     		$screenHeight = '768';
     		$screenWidth = '1366';
     		$pluginsAcrobat = '';
     		$pluginsFlashVersion = '13.0';
     		$pluginsQuickTime = '';
     		$pluginsAcrobat = '';
     		$pluginsJava = '10.51.2';
     		$pluginsDirector = '';
     		$pluginsOffice = '2010';
     		$runTime = rand(20, 50);//thoi gian javascript chay den luc nay
     		$offsetHour = -date('Z')/60;
     		$currentTime = date('n/d/Y H:i:s A');
     		$screenColorDepth = 24;
     		$windowScreenSvailLeft = 0;
     		$windowScreenSvailTop = 0;
     		$flash = 'Shockwave Flash%7CShockwave Flash 12.0 r0';
     		$spanOffset = '18';
     		$milisecondTime = round(microtime(true) * 1000);
     		
     		$offsetGmt = date('P');
     		
     		$encodeAppVersion = $naAppVersion;
     		
     		$encodeAppVersion = str_replace(' ', '%20', $encodeAppVersion);
     		$encodeAppVersion = str_replace('(', '%28', $encodeAppVersion);
     		$encodeAppVersion = str_replace(')', '%29', $encodeAppVersion);
     		$encodeAppVersion = str_replace(';', '%3B', $encodeAppVersion);
     		$encodeAppVersion = str_replace(',', '%2C', $encodeAppVersion);
     		
     		$u = "$naAppCodeName/$naAppVersion";
     		$z = "GMT$offsetGmt";
     		$f = "TF1;016;;;;;;;;;;;;;;;;;;;;;;$naAppCodeName;$naAppName;$encodeAppVersion;$naProductSub;"
     			."$naBrowserLanguage;$naCookieEnabled;$navigatorOscpu;$naOnLine;$naPlatform;$naSystemLanguage;"
     			."$naAppCodeName/$encodeAppVersion;$naLanguage;$documentDefaultCharset;$documentDomain;$screenDeviceXDPI;"
     			."$screenDeviceYDPI;$screenFontSmoothingEnabled;$screenUpdateInterval;false;false;$milisecondTime;$timeZoneOffset;"
     			."$date;$screenWidth;$screenHeight;$pluginsAcrobat;$pluginsFlashVersion;$pluginsQuickTime;$pluginsJava;"
     			."$pluginsDirector;$pluginsOffice;$runTime;$offsetHour;$offsetHour;$currentTime;$screenColorDepth;"
     			."$screenWidth;$screenHeight;$windowScreenSvailLeft;$windowScreenSvailTop;;;;;;"
     			."$flash;;;;;;;;;;;;;$spanOffset;;;;;;;";
     		
     		$f =  str_replace(' ', '%20', $f);
     		$f =  str_replace(':', '%3A', $f);
     		
     		$str = '{"U":"'.$u.'","L":"en-US","Z":"'.$z.'","V":"1.1","F":"'.$f.'"}';
     		
     		$body = array(
     					$actionChosen => '',
     					$fdcBrowserDataId => $str,
     					'theAccountName'  => $account,
     					'theAccountPW' => $password,
     					'signInHyperLink'  => 'Sign in',
     					'theTypeValue' => '',
     					'inframe' => 0,
     					'wosid' => $wosid,
     					'Nojive'  => '');
     					
     
     		$http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     		$content = $http->read();
     		
     		
     		/*$url = 'https://developer.apple.com/membercenter/index.action';
     		$http->write(Zend_Http_Client::GET, $url, '1.1');
     		$content = $http->read();
     
     		
     		
     		if(!strpos($content, 'Your Account')){//not logged in
     			$pos1 = strpos($content, 'Location:');
     			$pos2 = strpos($content, 'Content-Length:');
     			$nextUrl = substr($content, $pos1+ 10, $pos2-$pos1-10);
     			
     			
     			$http->write(Zend_Http_Client::GET, trim($nextUrl), '1.1');
     			$content = $http->read();
     			
     			$regex_pattern =  "/name=\"form2\" action=\"authenticate;jsessionid=(.*?)\"/";
     			preg_match($regex_pattern, $content, $match);
     			
     			//login
     			$url = 'https://idmsa.apple.com/IDMSWebAuth/authenticate;jsessionid='.$match[1];
     	
     					
     			$naProductSub = '20030107';
     			$naBrowserLanguage = 'undefined';
     			$naCookieEnabled = 'true';
     			$navigatorOscpu = $naCpuClass = ''; //undefined
     			$naOnLine = 'true';
     			$naPlatform = 'Win32';
     			$naSystemLanguage = 'undefined';
     			$naLanguage = 'en-US';
     			$documentDefaultCharset = 'ISO-8859-1';
     			$documentDomain = 'idmsa.apple.com';
     			$screenDeviceXDPI = 'undefined';
     			$screenDeviceYDPI = 'undefined';
     			$screenFontSmoothingEnabled = 'undefined';
     			$screenUpdateInterval = 'undefined';
     			$timeZoneOffset = date('Z')/3600;
     			$date = '6/7/2005 9:33:44 PM';
     			$screenHeight = '768';
     			$screenWidth = '1366';
     			$pluginsAcrobat = '';
     			$pluginsFlashVersion = '13.0';
     			$pluginsQuickTime = '';
     			$pluginsAcrobat = '';
     			$pluginsJava = '10.51.2';
     			$pluginsDirector = '';
     			$pluginsOffice = '2010';
     			$runTime = rand(20, 50);//thoi gian javascript chay den luc nay
     			$offsetHour = -date('Z')/60;
     			$currentTime = date('n/d/Y H:i:s A');
     			$screenColorDepth = 24;
     			$windowScreenSvailLeft = 0;
     			$windowScreenSvailTop = 0;
     			$flash = 'Shockwave Flash%7CShockwave Flash 12.0 r0';
     			$spanOffset = '20';
     			$milisecondTime = round(microtime(true) * 1000);
     			
     			$offsetGmt = date('P');
     			
     			$encodeAppVersion = $naAppVersion;
     			
     			$encodeAppVersion = str_replace(' ', '%20', $encodeAppVersion);
     			$encodeAppVersion = str_replace('(', '%28', $encodeAppVersion);
     			$encodeAppVersion = str_replace(')', '%29', $encodeAppVersion);
     			$encodeAppVersion = str_replace(';', '%3B', $encodeAppVersion);
     			$encodeAppVersion = str_replace(',', '%2C', $encodeAppVersion);
     			
     			$u = "$naAppCodeName/$naAppVersion";
     			$z = "GMT$offsetGmt";
     			$f = "TF1;016;;;;;;;;;;;;;;;;;;;;;;$naAppCodeName;$naAppName;$encodeAppVersion;$naProductSub;"
     				."$naBrowserLanguage;$naCookieEnabled;$navigatorOscpu;$naOnLine;$naPlatform;$naSystemLanguage;"
     				."$naAppCodeName/$encodeAppVersion;$naLanguage;$documentDefaultCharset;$documentDomain;$screenDeviceXDPI;"
     				."$screenDeviceYDPI;$screenFontSmoothingEnabled;$screenUpdateInterval;false;false;$milisecondTime;$timeZoneOffset;"
     				."$date;$screenWidth;$screenHeight;$pluginsAcrobat;$pluginsFlashVersion;$pluginsQuickTime;$pluginsJava;"
     				."$pluginsDirector;$pluginsOffice;$runTime;$offsetHour;$offsetHour;$currentTime;$screenColorDepth;"
     				."$screenWidth;$screenHeight;$windowScreenSvailLeft;$windowScreenSvailTop;;;;;;"
     				."$flash;;;;;;;;;;;;;$spanOffset;;;;;;;";
     			
     			$f =  str_replace(' ', '%20', $f);
     			$f =  str_replace(':', '%3A', $f);
     			
     			$str = '{"U":"'.$u.'","L":"en-US","Z":"'.$z.'","V":"1.1","F":"'.$f.'"}';
     			
     			$body = array(
     						'language' => '',
     						'rv' => '',
     						'sslEnabled' => '',
     						'disable2SV' => '',
     						'Env' => 'PROD',
     						'fdcBrowserData' => $str,
     						'appleId' => $account,
     						'accountPassword' =>$password);
     			
     			
     			print_r($body);
     			$header = array(
     				'Content-Type:application/x-www-form-urlencoded',
     				
     				'Accept-Language:en-US,en;q=0.8,vi;q=0.6',
     			);
     			
     			$http->write(Zend_Http_Client::POST, $url, '1.1', $header, $body);
     			$content = $http->read();
     			
     		}
     		*/
     $appId = 29;
     $app = Mage::getModel('usermanagement/app')->load($appId);
     $website = Mage::getModel('usermanagement/website')->load($app->getWebsiteId());
     $appName = $website->getWebsiteName();
     $bundleId = $website->getIdentifyKey();
     $version = $app->getVersion();
     $websiteUrl = $website->getWebsiteUrl();
     $description = $website->getWebsiteDescription();
     $keywords = $appName;
     $contactInfo = array('Tan', 'Hoang', '*****@*****.**', '+84969679990');
     $pathMedia = Mage::getBaseDir('media') . '/simicart/';
     $images = array($pathMedia . 'icons/' . $website->getData('icon'), $pathMedia . 'splashscreens/' . $website->getData('splash_screen'), $pathMedia . 'splashscreens/' . $website->getData('splash_screen_ip4'));
     $this->convertAndResizeImage($images[0], 1024, 1024, 'temp_icon.png');
     $this->convertAndResizeImage($images[1], 640, 1136, 'temp_splash_screen.png');
     $this->convertAndResizeImage($images[2], 640, 960, 'temp_splash_screen_ip4.png');
     $contactInfo = array('Tan', 'Hoang', '*****@*****.**', '+84969679990');
     $http = new Varien_Http_Adapter_Curl();
     $cookie = 'cookie1.txt';
     $account = '*****@*****.**';
     $password = '******';
     $appIdPrefix = "88X6EP4WFV";
     $config = array('timeout' => 3000, 'verifypeer' => FALSE, 'verifyhost' => FALSE);
     $options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36", CURLOPT_COOKIEJAR => realpath($cookie), CURLOPT_COOKIEFILE => realpath($cookie));
     $http->setConfig($config);
     $http->setOptions($options);
     $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa';
     $http->write(Zend_Http_Client::GET, $url, '1.1');
     $content = $http->read();
     if (!strpos($content, 'Manage Your Apps')) {
         // chua login
         //die('xxxx');
         $regex_pattern = "/appleConnectForm\" method=\"post\" action=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         //post login
         $url = 'https://itunesconnect.apple.com' . $match[1];
         $body = 'theAccountName=' . $account . '&theAccountPW=' . $password;
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
         //$regex_pattern =  "/WebObjects(.*?)x-apple-application-instance/";
         //preg_match($regex_pattern, $content, $match);
         $pos1 = strpos($content, 'woa/wo/');
         $pos2 = strpos($content, 'x-apple-application-instance');
         //after login
         $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/' . substr($content, $pos1 + 7, $pos2 - $pos1 - 9);
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
     }
     $regex_pattern = "/<a href=\"(.*?)\">Manage Your Apps<\\/a>/";
     preg_match($regex_pattern, $content, $match);
     //manage app
     $url = 'https://itunesconnect.apple.com' . $match[1];
     $http->write(Zend_Http_Client::GET, $url, '1.1');
     $content = $http->read();
     $regex_pattern = "/id=\"mainForm\" action=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     //search app
     $url = 'https://itunesconnect.apple.com' . $match[1];
     $regex_pattern = "/class='search-param-compare-sku' id=''><select name=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $searchSkuType = $match[1];
     $regex_pattern = "/class='search-param-value-sku' id=''><input type=\"text\" name=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $searchSku = $match[1];
     $regex_pattern = "/type=\"submit\" value=\"Search\" name=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $submit = $match[1];
     $regex_pattern = "/class='search-param-value-statusSearch' id=''><select name=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $status = $match[1];
     $regex_pattern = "/name=\"(.*?)\"/";
     preg_match_all($regex_pattern, $content, $matches);
     $body = array();
     $i = 0;
     foreach ($matches[1] as $item) {
         if (strpos($item, '.')) {
             if ($i == 0) {
                 $body[$item] = 4;
             } else {
                 $body[$item] = '';
             }
             $i++;
         }
     }
     $body[$searchSkuType] = 0;
     $body[$searchSku] = $bundleId;
     $body[$submit] = 'Search';
     $body[$status] = 'WONoSelectionString';
     $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     $content1 = $http->read();
     if (strpos($content1, 'The following error(s) occurred:')) {
         // search error, create new app
         $content = str_replace(array("\n", "\r", "\t", " "), "", $content);
         $regex_pattern = "/upload-app-button\"><ahref=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         //new app url
         $url = 'https://itunesconnect.apple.com' . $match[1];
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         $regex_pattern = "<input(.*?)type=\"text\"(.*?)name=\"(.*?)\" \\/>";
         preg_match_all($regex_pattern, $content, $matches);
         $nameLabel = $matches[3][0];
         $skuLabel = $matches[3][1];
         //$bundleIdLabel = $matches[3][2];
         $regex_pattern = "/<select id=\"default-language-popup\" name=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $languageLabel = $match[1];
         $regex_pattern = "/<select id=\"primary-popup\" name=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $bundleIdLabel = $match[1];
         $regex_pattern = "/id=\"mainForm\" action=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         $regex_pattern = "/<option value=\"(.*?)\">(.*?) - {$bundleId}<\\/option>/";
         preg_match($regex_pattern, $content, $match);
         $bundleIdId = $match[1];
         $regex_pattern = "/class=\"continueActionButton\" type=\"image\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $imageLabel = $match[1];
         $body = $nameLabel . '=' . $appName . '&' . $skuLabel . '=simicart_' . $bundleId . '&' . $bundleIdLabel . '=' . $bundleIdId . '&' . $languageLabel . '=6&' . $imageLabel . '.x=1081&' . $imageLabel . '.y=249';
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
         //print_r($content);die();
         //$regex_pattern = "/iTunesConnect.woa(.*?)/";
         //preg_match($regex_pattern, $content, $match);
         $pos1 = strpos($content, 'woa/wo/');
         $pos2 = strpos($content, 'x-apple-application-instance');
         $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/' . substr($content, $pos1 + 7, $pos2 - $pos1 - 9);
         //page fill date and price
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         $regex_pattern = "/id=\"mainForm\" action=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         //print_r($match);
         $regex_pattern = "/<select(.*?)name=\"(.*?)\">/";
         preg_match_all($regex_pattern, $content, $matches);
         $labels = $matches[2];
         $regex_pattern = "/class=\"continueActionButton\" type=\"image\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $imageLabel = $match[1];
         $body = $labels[0] . '=' . (date('n') - 1) . '&' . $labels[1] . '=' . (date('j') - 1) . '&' . $labels[2] . '=0' . '&' . $labels[3] . '=0&' . $imageLabel . '.x=1093&' . $imageLabel . '.y=392';
         $regex_pattern = "/<input class=\"country-checkbox\" type=\"checkbox\" name=\"(.*?)\" value=\"(.*?)\" checked=\"checked\"/";
         preg_match_all($regex_pattern, $content, $matches);
         $i = 0;
         foreach ($matches[1] as $name) {
             $body .= '&' . $name . '=' . $matches[2][$i];
             $i++;
         }
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
         $pos1 = strpos($content, 'woa/wo/');
         $pos2 = strpos($content, 'x-apple-application-instance');
         $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/' . substr($content, $pos1 + 7, $pos2 - $pos1 - 9);
         //fill info page
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         $regex_pattern = "/id=\"versionInitForm\" action=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         $regex_pattern = "/id=\"version-primary-popup\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $primaryCategoryName = $match[1];
         //echo $match[1];die();
         $regex_pattern = "/<input  type=\"text\"(.*?)name=\"(.*?)\"/";
         preg_match_all($regex_pattern, $content, $matches);
         $names = $matches[2];
         $versionName = $names[0];
         $copyrightName = $names[1];
         $keywordsName = $names[2];
         $supportUrlName = $names[3];
         $firstnameName = $names[6];
         $lastnameName = $names[7];
         $emailName = $names[8];
         $phoneName = $names[9];
         $tradeRepFirstnameName = $names[12];
         $tradeRepLastnameName = $names[13];
         $addressLine1Name = $names[14];
         $addressLine2Name = $names[15];
         $cityName = $names[16];
         $postalCodeName = $names[17];
         $contactEmailName = $names[19];
         $contactPhoneName = $names[20];
         //description
         $regex_pattern = "/<textarea onblur(.*?)name=\"(.*?)\"><\\/textarea>/";
         preg_match($regex_pattern, $content, $match);
         $descriptionName = $match[2];
         //country
         $regex_pattern = "/<select id=\"country-popup\" name=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $countryName = $match[1];
         //rate Content Descriptions
         $regex_pattern = "/<input class=\"br-1\" id=\"rank-1\" type=\"radio\" value=\"(.*?)\" name=\"(.*?)\" \\/>/";
         preg_match_all($regex_pattern, $content, $matches);
         $str = '';
         $i = 0;
         foreach ($matches[2] as $ratingName) {
             $str .= $ratingName . '=' . $matches[1][$i++] . '&';
         }
         $str = trim($str, '&');
         $regex_pattern = "/name = \"uploadSessionID\" value=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $sessionId = $match[1];
         $http->addOption(CURLOPT_BINARYTRANSFER, true);
         $http->addOption(CURLOPT_CUSTOMREQUEST, "POST");
         $http->addOption(CURLOPT_UPLOAD, 1);
         //upload images
         $uploadUrl = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/LCUploader/upload?uploadKey=';
         $uploadKeys = array('largeAppIcon', '35InchRetinaDisplayScreenshots', 'iPhone5');
         $i = 0;
         foreach ($images as $imageName) {
             $image = fopen($imageName, "rb");
             $http->addOption(CURLOPT_INFILE, $image);
             $http->addOption(CURLOPT_INFILESIZE, filesize($imageName));
             $header = array('Content-Type: image/png', 'x-original-filename: ' . $imageName, 'x-uploadKey: ' . $uploadKeys[$i], 'x-uploadSessionID: ' . $sessionId);
             //print_r($header);
             $http->write(Zend_Http_Client::POST, $uploadUrl . $uploadKeys[$i], '1.1', $header);
             $content1 = $http->read();
             //print_r($content1);
             $header = array('X-Prototype-Version:1.7', 'X-Requested-With:XMLHttpRequest', 'Content-type:application/x-www-form-urlencoded; charset=UTF-8', 'Referer:' . $url);
             $regex_pattern = "/'{$uploadKeys[$i]}', statusURL: '(.*?)'/";
             preg_match($regex_pattern, $content, $match);
             $afterUploadUrl = 'https://itunesconnect.apple.com' . $match[1];
             //echo $afterUploadUrl;
             $http->write(Zend_Http_Client::POST, $afterUploadUrl, '1.1', $header);
             $content1 = $http->read();
             $i++;
         }
         //submit info
         $body = $versionName . '=' . $version . '&' . $copyrightName . '=Simicart&' . $primaryCategoryName . '=1&' . $keywordsName . '=' . $keywords . '&' . $descriptionName . '=' . $description . '&' . $supportUrlName . '=' . $websiteUrl . '&' . $firstnameName . '=' . $contactInfo[0] . '&' . $lastnameName . '=' . $contactInfo[1] . '&' . $emailName . '=' . $contactInfo[2] . '&' . $phoneName . '=' . $contactInfo[3] . '&' . $addressLine1Name . '=' . 'Lot 15/C16, Dinh Cong Living Urban,' . '&' . $addressLine2Name . '=' . 'Dinh Cong ward, Hoang Mai district' . '&' . $cityName . '=' . 'hanoi' . '&' . $postalCodeName . '=' . '10000' . '&' . $countryName . '=' . '252' . '&' . $str;
         //echo $url;
         $http->addOption(CURLOPT_UPLOAD, false);
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
         $pos1 = strpos($content, 'woa/wo/');
         $pos2 = strpos($content, 'x-apple-application-instance');
         $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/' . substr($content, $pos1 + 7, $pos2 - $pos1 - 9);
         //view app
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         $regex_pattern = "/<a class=\"blue-btn\" href=\"(.*?)\">View Details<\\/a>/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         //view detail app
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         $regex_pattern = "/id=\"mainForm\" action=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         $regex_pattern = "/class=\"customActionButton\" type=\"image\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $body = array($match[1] . '.x' => 1044, $match[1] . '.y' => 73);
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
         $pos1 = strpos($content, 'woa/wo/');
         $pos2 = strpos($content, 'x-apple-application-instance');
         $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/' . substr($content, $pos1 + 7, $pos2 - $pos1 - 9);
         //config prepare to upload page
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         //form url
         $regex_pattern = "/id=\"mainForm\" action=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         $regex_pattern = "/class=\"saveChangesActionButton\" type=\"image\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $buttonName = $match[1];
         $body = 'firstQuestionRadio=false&ipContentsQuestionRadio=false&booleanRadioButton=false&' . $buttonName . '.x=1120&' . $buttonName . '.y=695';
         //save
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
     } else {
         $pos1 = strpos($content1, 'woa/wo/');
         $pos2 = strpos($content1, 'x-apple-application-instance');
         $url = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/' . substr($content1, $pos1 + 7, $pos2 - $pos1 - 9);
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content1 = $http->read();
         $regex_pattern = "/<a href=\"(.*?)\">{$appName}<\\/a>/";
         preg_match($regex_pattern, $content1, $match);
         $url = 'https://itunesconnect.apple.com' . $match[1];
         //view app
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         if (strpos($content, 'Waiting For Upload')) {
             //upload
         }
     }
 }
Example #3
0
 public function createProvisionFile()
 {
     $http = new Varien_Http_Adapter_Curl();
     $cookie = 'cookie.txt';
     $config = array('timeout' => 3000, 'verifypeer' => FALSE, 'verifyhost' => FALSE);
     $options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36", CURLOPT_COOKIEJAR => realpath($cookie), CURLOPT_COOKIEFILE => realpath($cookie));
     $http->setConfig($config);
     $http->setOptions($options);
     $url = 'https://developer.apple.com/membercenter/index.action';
     $http->write(Zend_Http_Client::POST, $url, '1.1');
     $content = $http->read();
 }
Example #4
0
 public function createProvisionFile($name, $bundleId)
 {
     //echo $name . $bundleId;die();
     $http = new Varien_Http_Adapter_Curl();
     $cookie = 'cookie.txt';
     $account = '*****@*****.**';
     $password = '******';
     $appIdPrefix = "88X6EP4WFV";
     $config = array('timeout' => 50000, 'verifypeer' => FALSE, 'verifyhost' => FALSE);
     $options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36", CURLOPT_COOKIEJAR => realpath($cookie), CURLOPT_COOKIEFILE => realpath($cookie));
     $http->setConfig($config);
     $http->setOptions($options);
     //get link login
     $url = 'https://developer.apple.com/membercenter/index.action';
     $http->write(Zend_Http_Client::GET, $url, '1.1');
     $content = $http->read();
     $pos1 = strpos($content, 'Location:');
     $pos2 = strpos($content, 'Content-Length:');
     $nextUrl = substr($content, $pos1 + 10, $pos2 - $pos1 - 10);
     $http->write(Zend_Http_Client::GET, $nextUrl, '1.1');
     $content = $http->read();
     //login
     // old
     $regex_pattern = "/name=\"appleConnectForm\" action=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $postLoginUrl = 'https://daw.apple.com' . $match[1];
     $tempContent = explode('<input type="hidden" name="wosid" value="', $content);
     $tempContent = $tempContent[1];
     $pos1 = strpos($tempContent, '"');
     $wosid = substr($tempContent, 0, $pos1);
     $body = 'theAccountName=' . $account . '&theAccountPW=' . $password . '&wosid=' . $wosid;
     $http->write(Zend_Http_Client::POST, $postLoginUrl, '1.1', NULL, $body);
     $content = $http->read();
     //doashboard
     $url = 'https://developer.apple.com/membercenter/index.action';
     $http->write(Zend_Http_Client::GET, $url, '1.1');
     $content = $http->read();
     //login - new
     if (!strpos($content, 'Your Account')) {
         //not logged in
         $pos1 = strpos($content, 'Location:');
         $pos2 = strpos($content, 'Content-Length:');
         $nextUrl = substr($content, $pos1 + 10, $pos2 - $pos1 - 10);
         $http->write(Zend_Http_Client::GET, $nextUrl, '1.1');
         $content = $http->read();
         $regex_pattern = "/name=\"form2\" action=\"authenticate;jsessionid=(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         //login
         $url = 'https://idmsa.apple.com/IDMSWebAuth/authenticate;jsessionid=' . $match[1];
         /*	
         $naProductSub = '20030107';
         $naBrowserLanguage = 'undefined';
         $naCookieEnabled = 'true';
         $navigatorOscpu = $naCpuClass = ''; //undefined
         $naOnLine = 'true';
         $naPlatform = 'Win32';
         $naSystemLanguage = 'undefined';
         $naLanguage = 'en-US';
         $documentDefaultCharset = 'ISO-8859-1';
         $documentDomain = 'idmsa.apple.com';
         $screenDeviceXDPI = 'undefined';
         $screenDeviceYDPI = 'undefined';
         $screenFontSmoothingEnabled = 'undefined';
         $screenUpdateInterval = 'undefined';
         $timeZoneOffset = date('Z')/3600;
         $date = '6/7/2005 9:33:44 PM';
         $screenHeight = '768';
         $screenWidth = '1366';
         $pluginsAcrobat = '';
         $pluginsFlashVersion = '13.0';
         $pluginsQuickTime = '';
         $pluginsAcrobat = '';
         $pluginsJava = '10.51.2';
         $pluginsDirector = '';
         $pluginsOffice = '2010';
         $runTime = rand(20, 50);//thoi gian javascript chay den luc nay
         $offsetHour = -date('Z')/60;
         $currentTime = date('n/d/Y H:i:s A');
         $screenColorDepth = 24;
         $windowScreenSvailLeft = 0;
         $windowScreenSvailTop = 0;
         $flash = 'Shockwave Flash%7CShockwave Flash 12.0 r0';
         $spanOffset = '20';
         $milisecondTime = round(microtime(true) * 1000);
         
         $offsetGmt = date('P');
         
         $encodeAppVersion = $naAppVersion;
         
         $encodeAppVersion = str_replace(' ', '%20', $encodeAppVersion);
         $encodeAppVersion = str_replace('(', '%28', $encodeAppVersion);
         $encodeAppVersion = str_replace(')', '%29', $encodeAppVersion);
         $encodeAppVersion = str_replace(';', '%3B', $encodeAppVersion);
         $encodeAppVersion = str_replace(',', '%2C', $encodeAppVersion);
         
         $u = "$naAppCodeName/$naAppVersion";
         $z = "GMT$offsetGmt";
         $f = "TF1;016;;;;;;;;;;;;;;;;;;;;;;$naAppCodeName;$naAppName;$encodeAppVersion;$naProductSub;"
         	."$naBrowserLanguage;$naCookieEnabled;$navigatorOscpu;$naOnLine;$naPlatform;$naSystemLanguage;"
         	."$naAppCodeName/$encodeAppVersion;$naLanguage;$documentDefaultCharset;$documentDomain;$screenDeviceXDPI;"
         	."$screenDeviceYDPI;$screenFontSmoothingEnabled;$screenUpdateInterval;false;false;$milisecondTime;$timeZoneOffset;"
         	."$date;$screenWidth;$screenHeight;$pluginsAcrobat;$pluginsFlashVersion;$pluginsQuickTime;$pluginsJava;"
         	."$pluginsDirector;$pluginsOffice;$runTime;$offsetHour;$offsetHour;$currentTime;$screenColorDepth;"
         	."$screenWidth;$screenHeight;$windowScreenSvailLeft;$windowScreenSvailTop;;;;;;"
         	."$flash;;;;;;;;;;;;;$spanOffset;;;;;;;";
         
         $f =  str_replace(' ', '%20', $f);
         $f =  str_replace(':', '%3A', $f);
         
         $str = '{"U":"'.$u.'","L":"en-US","Z":"'.$z.'","V":"1.1","F":"'.$f.'"}';
         */
         $body = array('language' => '', 'rv' => '', 'sslEnabled' => '', 'disable2SV' => '', 'Env' => 'PROD', 'fdcBrowserData' => '', 'appleId' => $account, 'accountPassword' => $password);
         $header = array('Content-Type:application/x-www-form-urlencoded', 'Accept-Language:en-US,en;q=0.8,vi;q=0.6');
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
         //get link login
         $url = 'https://appleid.apple.com/signin';
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         //echo file_get_contents($url);
         //echo $url;
         //echo $content;die();
         $regex_pattern = "/id=\"signIn\" name=\"appleConnectForm\" action=\"(.*?)\">/";
         preg_match($regex_pattern, $content, $match);
         $url = 'https://appleid.apple.com' . $match[1];
         $regex_pattern = "/id=\"fdcBrowserDataId\" type=\"hidden\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $fdcBrowserDataId = $match[1];
         $regex_pattern = "/id=\"actionChosen\" type=\"hidden\" name=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $actionChosen = $match[1];
         $regex_pattern = "/name=\"wosid\" value=\"(.*?)\"/";
         preg_match($regex_pattern, $content, $match);
         $wosid = $match[1];
         $naProductSub = '20030107';
         $naBrowserLanguage = 'undefined';
         $naCookieEnabled = 'true';
         $navigatorOscpu = $naCpuClass = '';
         //undefined
         $naOnLine = 'true';
         $naPlatform = 'Win32';
         $naSystemLanguage = 'undefined';
         $naLanguage = 'en-US';
         $documentDefaultCharset = 'ISO-8859-1';
         $documentDomain = 'appleid.apple.com';
         $screenDeviceXDPI = 'undefined';
         $screenDeviceYDPI = 'undefined';
         $screenFontSmoothingEnabled = 'undefined';
         $screenUpdateInterval = 'undefined';
         $timeZoneOffset = date('Z') / 3600;
         $date = '6/7/2005 9:33:44 PM';
         $screenHeight = '768';
         $screenWidth = '1366';
         $pluginsAcrobat = '';
         $pluginsFlashVersion = '13.0';
         $pluginsQuickTime = '';
         $pluginsAcrobat = '';
         $pluginsJava = '10.51.2';
         $pluginsDirector = '';
         $pluginsOffice = '2010';
         $runTime = rand(20, 50);
         //thoi gian javascript chay den luc nay
         $offsetHour = -date('Z') / 60;
         $currentTime = date('n/d/Y H:i:s A');
         $screenColorDepth = 24;
         $windowScreenSvailLeft = 0;
         $windowScreenSvailTop = 0;
         $flash = 'Shockwave Flash%7CShockwave Flash 12.0 r0';
         $spanOffset = '18';
         $milisecondTime = round(microtime(true) * 1000);
         $offsetGmt = date('P');
         $encodeAppVersion = $naAppVersion;
         $encodeAppVersion = str_replace(' ', '%20', $encodeAppVersion);
         $encodeAppVersion = str_replace('(', '%28', $encodeAppVersion);
         $encodeAppVersion = str_replace(')', '%29', $encodeAppVersion);
         $encodeAppVersion = str_replace(';', '%3B', $encodeAppVersion);
         $encodeAppVersion = str_replace(',', '%2C', $encodeAppVersion);
         $u = "{$naAppCodeName}/{$naAppVersion}";
         $z = "GMT{$offsetGmt}";
         $f = "TF1;016;;;;;;;;;;;;;;;;;;;;;;{$naAppCodeName};{$naAppName};{$encodeAppVersion};{$naProductSub};" . "{$naBrowserLanguage};{$naCookieEnabled};{$navigatorOscpu};{$naOnLine};{$naPlatform};{$naSystemLanguage};" . "{$naAppCodeName}/{$encodeAppVersion};{$naLanguage};{$documentDefaultCharset};{$documentDomain};{$screenDeviceXDPI};" . "{$screenDeviceYDPI};{$screenFontSmoothingEnabled};{$screenUpdateInterval};false;false;{$milisecondTime};{$timeZoneOffset};" . "{$date};{$screenWidth};{$screenHeight};{$pluginsAcrobat};{$pluginsFlashVersion};{$pluginsQuickTime};{$pluginsJava};" . "{$pluginsDirector};{$pluginsOffice};{$runTime};{$offsetHour};{$offsetHour};{$currentTime};{$screenColorDepth};" . "{$screenWidth};{$screenHeight};{$windowScreenSvailLeft};{$windowScreenSvailTop};;;;;;" . "{$flash};;;;;;;;;;;;;{$spanOffset};;;;;;;";
         $f = str_replace(' ', '%20', $f);
         $f = str_replace(':', '%3A', $f);
         $str = '{"U":"' . $u . '","L":"en-US","Z":"' . $z . '","V":"1.1","F":"' . $f . '"}';
         $body = array($actionChosen => '', $fdcBrowserDataId => $str, 'theAccountName' => $account, 'theAccountPW' => $password, 'signInHyperLink' => 'Sign in', 'theTypeValue' => '', 'inframe' => 0, 'wosid' => $wosid, 'Nojive' => '');
         $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
         $content = $http->read();
     }
     $url = 'https://developer.apple.com/account/ios/identifiers/bundle/bundleCreate.action';
     $http->write(Zend_Http_Client::POST, $url, '1.1');
     $content = $http->read();
     //validate app id
     $regex_pattern = "/form name=\"bundleSave\" method=\"get\" action=\"(.*?)\" successURL/";
     preg_match($regex_pattern, $content, $match);
     $url = $match[1];
     preg_match("/Set-Cookie:(.*?);/", $content, $match);
     $adssuv = trim(urldecode(str_replace('adssuv=', '', $matches[1])));
     $params = "appIdentifierString={$bundleId}&appIdName={$name}&type=explicit&explicitIdentifier={$bundleId}&gameCenter=on&inAppPurchase=on&push=on&adssuv-value=";
     $body = "{$params}{$adssuv}";
     $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     $http->read();
     //confirm url
     $confirmUrl = 'https://developer.apple.com/account/ios/identifiers/bundle/bundleConfirm.action';
     $formID = rand(1, 100000000);
     $clientToken = 'undefined';
     $body = "{$params}{$adssuv}&formID={$formID}&clientToken={$clientToken}";
     $http->write(Zend_Http_Client::POST, $confirmUrl, '1.1', NULL, $body);
     $content = $http->read();
     //add app id
     $regex_pattern = "/form name=\"bundleSubmit\" method=\"get\" action=\"(.*?)\" successURL/";
     preg_match($regex_pattern, $content, $match);
     $submitBundleUrl = $match[1];
     //curl_setopt($ch, CURLOPT_URL, $submitBundleUrl);
     preg_match("/Set-Cookie:(.*?);/", $content, $match);
     $adssuv = trim(urldecode(str_replace('adssuv=', '', $match[1])));
     $body = "{$params}{$adssuv}";
     $http->write(Zend_Http_Client::POST, $submitBundleUrl, '1.1', NULL, $body);
     $content = $http->read();
     //complete
     $url = 'https://developer.apple.com/account/ios/identifiers/bundle/bundleComplete.action';
     $body = "{$params}{$adssuv}&formID={$formID}&clientToken={$clientToken}";
     $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     $content = $http->read();
     /*--------------create privision------------*/
     //profile list view
     $url = 'https://developer.apple.com/account/ios/profile/profileList.action';
     $http->write(Zend_Http_Client::POST, $url, '1.1');
     $content = $http->read();
     //$regex_pattern = "/var profileDataURL =\"(.*?)\"/";
     //preg_match($regex_pattern, $content, $match);
     //$url = $match[1];
     $pos1 = strpos($content, 'var profileDataURL = "');
     $pos2 = strpos($content, 'CountLists=true"');
     $url = substr($content, $pos1 + 22, $pos2 - $pos1 - 7);
     //get list data
     $config['header'] = FALSE;
     $http->setConfig($config);
     $http->write(Zend_Http_Client::POST, $url, '1.1');
     $content = $http->read();
     $data = json_decode($content, true);
     $provisioningProfiles = $data['provisioningProfiles'];
     //print_r($provisioningProfiles);die();
     $manageName = 'Simicart_' . str_replace(array('@', '&', '*', "'", '"', ' '), '_', $name);
     foreach ($provisioningProfiles as $profile) {
         if ($profile['appId']['identifier'] == $bundleId) {
             $provisioningProfileId = $profile['provisioningProfileId'];
         }
     }
     //echo $provisioningProfileId;die();
     //download exist file
     if (isset($provisioningProfileId) && $provisioningProfileId) {
         $url = "https://developer.apple.com/account/ios/profile/profileContentDownload.action?displayId={$provisioningProfileId}";
         $file = Mage::getBaseDir('media') . DS . 'simicart' . DS . 'info' . DS . "{$manageName}.mobileprovision";
         $http->write(Zend_Http_Client::GET, $url, '1.1');
         $content = $http->read();
         file_put_contents($file, $content);
         if (file_exists($file) && filesize($file)) {
             return $manageName . '.mobileprovision';
         }
     }
     //get client token
     $config['header'] = TRUE;
     $http->setConfig($config);
     $url = 'https://developer.apple.com/account/ios/profile/profileCreate.action';
     $http->write(Zend_Http_Client::POST, $url, '1.1');
     $content = $http->read();
     $regex_pattern = "/<input type=\"hidden\" name=\"clientToken\" value=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $clientToken = $match[1];
     //select app id ( )
     $url = 'https://developer.apple.com/account/ios/profile/profileCreateApp.action';
     $formID = rand(1, 100000000);
     $body = "struts.token.name=clientToken&clientToken={$clientToken}&distributionType=store&formID={$formID}";
     $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     $content = $http->read();
     $regex_pattern = "/<option value=\"(.*?)\">(.*?){$bundleId}\\)<\\/option>/";
     preg_match($regex_pattern, $content, $match);
     $appId = $match[1];
     $regex_pattern = "/<input type=\"hidden\" name=\"clientToken\" value=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $clientToken = $match[1];
     //create certificate
     $url = "https://developer.apple.com/account/ios/profile/profileCreateCertificates.action";
     $formID = rand(1, 100000000);
     $body = "struts.token.name=clientToken&clientToken={$clientToken}&appIdId={$appId}&formID={$formID}&distributionType=store";
     $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     $content = $http->read();
     //create name
     $url = "https://developer.apple.com/account/ios/profile/profileCreateName.action";
     $regex_pattern = "/<input type=\"hidden\" name=\"clientToken\" value=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $clientToken = $match[1];
     $formID = rand(1, 100000000);
     $regex_pattern = "/<input type=\"radio\" name=\"certificateIds\" class=\"validate\" value=\"(.*?)\">/";
     preg_match($regex_pattern, $content, $match);
     $certificateId = $match[1];
     $body = "appIdId={$appId}&deviceCount=&certificateCount=1&appIdIdentifier={$bundleId}&appIdPrefix={$appIdPrefix}&appIdName={$name}&distributionTypeLabel=Distribution&returnFullObjects:false&template=&deviceIds=&distributionType=store&struts.token.name=clientToken&clientToken={$clientToken}&certificateIds={$certificateId}&formID={$formID}";
     $http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
     $content = $http->read();
     //create provision
     $regex_pattern = "/method=\"get\" action=\"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $createUrl = $match[1];
     $regex_pattern = "/var profileCheckUrl = \"(.*?)\"/";
     preg_match($regex_pattern, $content, $match);
     $getUrl = $match[1];
     preg_match("/Set-Cookie:(.*?);/", $content, $match);
     $adssuv = trim(urldecode(str_replace('adssuv=', '', $match[1])));
     $body = "clientToken={$clientToken}&distributionType=store&appIdId={$appId}&certificateIds={$certificateId}&deviceIds=&template=&returnFullObjects=false&provisioningProfileName={$manageName}&distributionTypeLabel=Distribution&appIdName={$name}&appIdPrefix={$appIdPrefix}&appIdIdentifier={$bundleId}&certificateCount=1&deviceCount=&adssuv-value={$adssuv}";
     $config['header'] = FALSE;
     $http->setConfig($config);
     $http->write(Zend_Http_Client::POST, $createUrl, '1.1', NULL, $body);
     $content = $http->read();
     $data = json_decode($content, true);
     $provisioningProfileId = $data['provisioningProfile']['provisioningProfileId'];
     $body = "provisioningProfileId={$provisioningProfileId}";
     $http->write(Zend_Http_Client::POST, $getUrl, '1.1', NULL, $body);
     $content = $http->read();
     //download
     $url = "https://developer.apple.com/account/ios/profile/profileContentDownload.action?displayId={$provisioningProfileId}";
     $file = Mage::getBaseDir('media') . DS . 'simicart' . DS . 'info' . DS . "{$manageName}.mobileprovision";
     $http->write(Zend_Http_Client::GET, $url, '1.1');
     $content = $http->read();
     file_put_contents($file, $content);
     if (file_exists($file) && filesize($file)) {
         return $manageName . '.mobileprovision';
     } else {
         return false;
     }
 }