使用无法在Symfony中运行的api函数生成报告

时间:2018-07-11 10:54:12

标签: php symfony

我正在生成报告功能。当访问页面URL时,它使用curl request从api获取数据。在嵌入式代码中,我使用了一个函数getProfileMarketplace函数,该函数不返回任何响应,结果导致无法生成报告。在用户捆绑包中定义profile_marketplace函数,并在顶部将其定义为私有。用户存储库功能用于获取活动的ppc用户。

控制器代码

public function ppcReports()
    {
        /** @var CurlRequest $curlRequest */
        $curlRequest = $this->get('app.advertise.request');
        $entityManager = $this->getDoctrine()->getManager();
        $users = $entityManager->getRepository('UserBundle:User')->getActivePPCUsers();
       foreach($users as $user) 
       {

         $refresh_token = $user->getRefreshToken();
        $marketplace = $user->getProfileMarketplace();
           //var_dump($marketplace);
         $regionResponse = $curlRequest->regionBymarketplace($marketplace) ;
         $region = json_decode($regionResponse->getContent());

        $AdvertiseProfile = $entityManager->getRepository('AppBundle:AdvertiseProfile')->getUserProfile($user->getId());

          if(!empty($AdvertiseProfile))
          {
              $profiles =  $AdvertiseProfile[0]->getProfileDetails();
             $requestParameter = array("userId"=>$user->getId(),
                                      "refreshToken" => $refresh_token,
                                      "region" => $region->region,
                                      "sandbox" => $region->sandbox,
                                      "profiles" => $profiles
                                    ) ;

          $req_date = date('Ymd',strtotime("-1 days"));
          $reportTypes = array('campaigns','adGroups','keywords','productAds') ;

              foreach($reportTypes as $reportType)
              {
                  switch ($reportType) {
                    case "campaigns":
                        $reportData = array(
                              "requestType" => "campaigns",
                               "campaignType" => "sponsoredProducts",
                               "reportDate" => $req_date ,
                               "metrics" => "impressions,clicks,cost,avgImpressionPosition,attributedConversions1dSameSKU,attributedSales1dSameSKU,attributedConversions14dSameSKU,attributedSales14dSameSKU,attributedConversions7dSameSKU,attributedSales7dSameSKU,attributedConversions30dSameSKU,attributedSales30dSameSKU"
                              ) ; 


                        break;
                    case "adGroups":
                       $reportData = array(
                              "requestType" => "adGroups",
                               "campaignType" => "sponsoredProducts",
                               "reportDate" => $req_date ,
                               "metrics" => "impressions,clicks,cost,avgImpressionPosition,attributedConversions1dSameSKU,attributedSales1dSameSKU,attributedConversions14dSameSKU,attributedSales14dSameSKU,attributedConversions7dSameSKU,attributedSales7dSameSKU,attributedConversions30dSameSKU,attributedSales30dSameSKU"
                              ) ; 


                        break;
                    case "keywords":
                        $reportData = array(
                             "requestType" => "keywords",
                             "campaignType" => "sponsoredProducts",
                               "reportDate" => $req_date ,
                               "segment" => "query",
                               "metrics" => "impressions,clicks,cost,avgImpressionPosition,attributedConversions1dSameSKU,attributedSales1dSameSKU,attributedConversions14dSameSKU,attributedSales14dSameSKU,attributedConversions7dSameSKU,attributedSales7dSameSKU,attributedConversions30dSameSKU,attributedSales30dSameSKU"
                              ) ; 

                        break;
                    case "productAds":
                        $reportData = array(
                             "requestType" => "productAds",
                             "campaignType" => "sponsoredProducts",
                               "reportDate" => $req_date ,
                               "metrics" => "impressions,clicks,cost,avgImpressionPosition,attributedConversions1dSameSKU,attributedSales1dSameSKU,attributedConversions14dSameSKU,attributedSales14dSameSKU,attributedConversions7dSameSKU,attributedSales7dSameSKU,attributedConversions30dSameSKU,attributedSales30dSameSKU,sku,asin,currency,campaignId,adGroupId,campaignName,adGroupName"
                              ) ; 


                   }

                $Reportresponse = $curlRequest->genratereport($requestParameter,$reportData);
              }


            }           


        } 
        die('done for all reports');
    }

应用捆绑包代码:

public function getProfileMarketplace()
    {
        return $this->profile_marketplace;

    }

0 个答案:

没有答案