如何提高此PHP控制器的速度?

发布于 2025-01-31 09:28:23 字数 4164 浏览 3 评论 0原文

如下所示,有一个控制器结构可以从Instagram中获取各种数据,并在提取此数据后计算参与率。尽管该结构在小规模帐户中很快起作用,但在大帐户上,它的效率非常慢且效率低下。我试图通过尝试各种方法(例如使用收益率方法)来加快速度,但是由于我是PHP的新手,我什至不确定是否应该在此代码中使用屈服。您能帮我做什么吗?提前致谢。

这是我的控制器代码

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Http;

class splenperAPIController extends Controller
{    
    public function splenperAPI()
    {
        $maxId = '';
        $response = Http::withHeaders([
            'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
            'x-ig-app-id' => '936619743392459',
            'Content-Type' => 'application/json',
        ])->get('https://www.instagram.com/elmaligroup/?__a=1');
        $response = $response->json();

        $userId = $response['graphql']['user']['id'];
        $followersCount = $response['graphql']['user']['edge_followed_by']['count'];
        $count = 12;

        $index = 0;
        $isMoreAvailable = true;

        $totalLikeCount = 0;
        $totalCommentCount = 0;

        while ($index < $count && $isMoreAvailable) {
            $variables = json_encode([
                'id' => $userId,
                "after" => $maxId,
                "first" => $count,
            ]);

            $variables = urlencode($variables);
            $response = Http::withHeaders([
                'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
                'x-ig-app-id' => '936619743392459',
                'Content-Type' => 'application/json',
            ])->get('https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables=' . $variables);
            
            
            
            for ($i = 0; $i < $count; $i++) {
                if ($i == count($response->json()['data']['user']['edge_owner_to_timeline_media']['edges'])) {
                    break;
                }
                $totalCommentCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_to_comment']['count'];
                $totalLikeCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_preview_like']['count'];
                $userName = $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['owner']['username'];
                $index++;

            }

            $maxId = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor'];
            $isMoreAvailable = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['has_next_page'];
            if ($isMoreAvailable) {
                $index = 0;
            }

        }
        $mediaCount = $response->json()['data']['user']['edge_owner_to_timeline_media']['count'];



        echo $followersCount . '<br>';
        echo $totalLikeCount . '<br>';
        echo $totalCommentCount . '<br>';
        echo ($totalLikeCount + $totalCommentCount) . '<br>';
        echo $userName . '<br>';
        echo $userId . '<br>';
        echo $mediaCount . '<br>';

        $percent = ($totalLikeCount + $totalCommentCount) / $followersCount * 100;
        echo "engagementRate: " . number_format($percent, 2, ',', '.') . '%';

    }
    
}

As you can see below, there is a controller structure that pulls various data from Instagram and calculates the engagement rate after pulling this data. Although this structure works fast in small-scale accounts, it becomes very slow and inefficient when it comes to large accounts. I tried to speed it up by trying various things, such as using the yield method, but since I'm new to php, I'm not even sure if I should use yield in this code. Could you please help me on what to do? Thanks in advance.

this is my controller code

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Http;

class splenperAPIController extends Controller
{    
    public function splenperAPI()
    {
        $maxId = '';
        $response = Http::withHeaders([
            'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
            'x-ig-app-id' => '936619743392459',
            'Content-Type' => 'application/json',
        ])->get('https://www.instagram.com/elmaligroup/?__a=1');
        $response = $response->json();

        $userId = $response['graphql']['user']['id'];
        $followersCount = $response['graphql']['user']['edge_followed_by']['count'];
        $count = 12;

        $index = 0;
        $isMoreAvailable = true;

        $totalLikeCount = 0;
        $totalCommentCount = 0;

        while ($index < $count && $isMoreAvailable) {
            $variables = json_encode([
                'id' => $userId,
                "after" => $maxId,
                "first" => $count,
            ]);

            $variables = urlencode($variables);
            $response = Http::withHeaders([
                'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
                'x-ig-app-id' => '936619743392459',
                'Content-Type' => 'application/json',
            ])->get('https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables=' . $variables);
            
            
            
            for ($i = 0; $i < $count; $i++) {
                if ($i == count($response->json()['data']['user']['edge_owner_to_timeline_media']['edges'])) {
                    break;
                }
                $totalCommentCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_to_comment']['count'];
                $totalLikeCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_preview_like']['count'];
                $userName = $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['owner']['username'];
                $index++;

            }

            $maxId = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor'];
            $isMoreAvailable = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['has_next_page'];
            if ($isMoreAvailable) {
                $index = 0;
            }

        }
        $mediaCount = $response->json()['data']['user']['edge_owner_to_timeline_media']['count'];



        echo $followersCount . '<br>';
        echo $totalLikeCount . '<br>';
        echo $totalCommentCount . '<br>';
        echo ($totalLikeCount + $totalCommentCount) . '<br>';
        echo $userName . '<br>';
        echo $userId . '<br>';
        echo $mediaCount . '<br>';

        $percent = ($totalLikeCount + $totalCommentCount) / $followersCount * 100;
        echo "engagementRate: " . number_format($percent, 2, ',', '.') . '%';

    }
    
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

万劫不复 2025-02-07 09:28:23

我已经使用 microtime memory_get_usage 之后(或者如果可以的话/code> laravel log)脚本运行,您将能够在脚本完成后查看有关时间,内存和统计数据的一些统计数据,然后更新问题,我们可以考虑下一步

public function splenperAPI()
  {
    $workStart = microtime(true);

    $headers = [
      'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
      'x-ig-app-id' => '936619743392459',
      'Content-Type' => 'application/json',
    ];
    $maxId = '';
    $response = Http::withHeaders($headers)->get('https://www.instagram.com/elmaligroup/?__a=1');
    $response = $response->json();

    $userId = $response['graphql']['user']['id'];
    $followersCount = $response['graphql']['user']['edge_followed_by']['count'];
    $count = 12;

    $index = 0;
    $isMoreAvailable = true;

    $totalLikeCount = 0;
    $totalCommentCount = 0;
    // debug vars
    $requestsCount = 0;
    $slowestRequestTime = 0;
    $totalRequestsTime = 0;
    $totalProcessingDataTime = 0;
    // debug vars end

    while ($index < $count && $isMoreAvailable) {
      $variables = urlencode(
        json_encode([
          'id' => $userId,
          "after" => $maxId,
          "first" => $count,
        ])
      );

      // we'll log requests durations
      $startTime = microtime(true);
      $response = Http::withHeaders($headers)
        ->get("https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables=$variables");
      $endTime = microtime(true);

      $requestsCount++;
      $requestTime = round($endTime - $startTime, 6);
      $totalRequestsTime += $requestTime;
      if ($requestTime > $slowestRequestTime) $slowestRequestTime = $requestTime;

      // also we'll log processing requested data duration 
      $startTime = microtime(true);
      for ($i = 0; $i < $count; $i++) {
        if ($i == count($response->json()['data']['user']['edge_owner_to_timeline_media']['edges'])) {
          break;
        }
        $totalCommentCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_to_comment']['count'];
        $totalLikeCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_preview_like']['count'];
        $userName = $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['owner']['username'];
        $index++;
      }

      $maxId = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor'];
      $isMoreAvailable = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['has_next_page'];
      if ($isMoreAvailable) {
        $index = 0;
      }
      $endTime = microtime(true);
      $processingDataTime = round($endTime - $startTime, 6);
      $totalProcessingDataTime += $processingDataTime;
      Log::debug('speed', [
        'request time' => $requestTime,
        'process data time' => $processingDataTime,
        'current memory usage (MB)' => memory_get_usage() / 1048576
      ]);
    }
    $workDuration = round(microtime(true) - $workStart, 6);
    // and the final log to get total data
    Log::debug('speed', [
      'total requests' => $requestsCount,
      'total network time' => $totalRequestsTime,
      'slowest' => $slowestRequestTime,
      'average' => round($totalRequestsTime / $requestsCount, 6),
      'total processing time' => $totalProcessingDataTime,
      'total work time' => $workDuration,
      'memory peak (MB)' =>  memory_get_peak_usage() / 1048576
    ]);
    $mediaCount = $response->json()['data']['user']['edge_owner_to_timeline_media']['count'];

    echo $followersCount . '<br>';
    echo $totalLikeCount . '<br>';
    echo $totalCommentCount . '<br>';
    echo ($totalLikeCount + $totalCommentCount) . '<br>';
    echo $userName . '<br>';
    echo $userId . '<br>';
    echo $mediaCount . '<br>';

    $percent = ($totalLikeCount + $totalCommentCount) / $followersCount * 100;
    echo "engagementRate: " . number_format($percent, 2, ',', '.') . '%';
  }

i've made a basic benchmark with microtime and memory_get_usage so after (or while if you can tail laravel log) script runs you will be able to see some stats about timings and memory and overal stats after script finish, then update question and we can think about next steps

public function splenperAPI()
  {
    $workStart = microtime(true);

    $headers = [
      'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
      'x-ig-app-id' => '936619743392459',
      'Content-Type' => 'application/json',
    ];
    $maxId = '';
    $response = Http::withHeaders($headers)->get('https://www.instagram.com/elmaligroup/?__a=1');
    $response = $response->json();

    $userId = $response['graphql']['user']['id'];
    $followersCount = $response['graphql']['user']['edge_followed_by']['count'];
    $count = 12;

    $index = 0;
    $isMoreAvailable = true;

    $totalLikeCount = 0;
    $totalCommentCount = 0;
    // debug vars
    $requestsCount = 0;
    $slowestRequestTime = 0;
    $totalRequestsTime = 0;
    $totalProcessingDataTime = 0;
    // debug vars end

    while ($index < $count && $isMoreAvailable) {
      $variables = urlencode(
        json_encode([
          'id' => $userId,
          "after" => $maxId,
          "first" => $count,
        ])
      );

      // we'll log requests durations
      $startTime = microtime(true);
      $response = Http::withHeaders($headers)
        ->get("https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables=$variables");
      $endTime = microtime(true);

      $requestsCount++;
      $requestTime = round($endTime - $startTime, 6);
      $totalRequestsTime += $requestTime;
      if ($requestTime > $slowestRequestTime) $slowestRequestTime = $requestTime;

      // also we'll log processing requested data duration 
      $startTime = microtime(true);
      for ($i = 0; $i < $count; $i++) {
        if ($i == count($response->json()['data']['user']['edge_owner_to_timeline_media']['edges'])) {
          break;
        }
        $totalCommentCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_to_comment']['count'];
        $totalLikeCount += $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['edge_media_preview_like']['count'];
        $userName = $response->json()['data']['user']['edge_owner_to_timeline_media']['edges'][$i]['node']['owner']['username'];
        $index++;
      }

      $maxId = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor'];
      $isMoreAvailable = $response->json()['data']['user']['edge_owner_to_timeline_media']['page_info']['has_next_page'];
      if ($isMoreAvailable) {
        $index = 0;
      }
      $endTime = microtime(true);
      $processingDataTime = round($endTime - $startTime, 6);
      $totalProcessingDataTime += $processingDataTime;
      Log::debug('speed', [
        'request time' => $requestTime,
        'process data time' => $processingDataTime,
        'current memory usage (MB)' => memory_get_usage() / 1048576
      ]);
    }
    $workDuration = round(microtime(true) - $workStart, 6);
    // and the final log to get total data
    Log::debug('speed', [
      'total requests' => $requestsCount,
      'total network time' => $totalRequestsTime,
      'slowest' => $slowestRequestTime,
      'average' => round($totalRequestsTime / $requestsCount, 6),
      'total processing time' => $totalProcessingDataTime,
      'total work time' => $workDuration,
      'memory peak (MB)' =>  memory_get_peak_usage() / 1048576
    ]);
    $mediaCount = $response->json()['data']['user']['edge_owner_to_timeline_media']['count'];

    echo $followersCount . '<br>';
    echo $totalLikeCount . '<br>';
    echo $totalCommentCount . '<br>';
    echo ($totalLikeCount + $totalCommentCount) . '<br>';
    echo $userName . '<br>';
    echo $userId . '<br>';
    echo $mediaCount . '<br>';

    $percent = ($totalLikeCount + $totalCommentCount) / $followersCount * 100;
    echo "engagementRate: " . number_format($percent, 2, ',', '.') . '%';
  }
怀里藏娇 2025-02-07 09:28:23

我相信这里的最大问题是您正在执行的HTTP请求的数量。我认为您必须增加每个请求的数量。它将减少HTTP请求,并可能加速您的代码。

您将其设置在$ count = 12;

i重构您的代码并放置$ MAXPERPAGE = 50,并尝试减少一些不必要的计数,并呼吁Method $ response- &gt; json()

    $headers = [
        'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
        'x-ig-app-id' => '936619743392459',
        'Content-Type' => 'application/json',
    ];
    $response = Http::withHeaders($headers)->get('https://www.instagram.com/elmaligroup/?__a=1');
    $response = $response->json();

    $userId = $response['graphql']['user']['id'];
    $followersCount = $response['graphql']['user']['edge_followed_by']['count'];
    $maxPerPage = 50;
    $endCursor = '';
    $hasNextPage = true;
    $totalLikeCount = 0;
    $totalCommentCount = 0;
    $userName = '';
    $mediaCount = 0;

    while ($hasNextPage) {

        $variables = urlencode(json_encode([
            "id" => $userId,
            "after" => $endCursor,
            "first" => $maxPerPage,
        ]));

        $response = Http::withHeaders($headers)->get('https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables=' . $variables);


        $edges = $response->json()['data']['user']['edge_owner_to_timeline_media'];
        $totalOfEdges = count($edges['edges']);

        for ($i = 0; $i < $totalOfEdges; $i++) {
            $totalCommentCount += $edges['edges'][$i]['node']['edge_media_to_comment']['count'];
            $totalLikeCount += $edges['edges'][$i]['node']['edge_media_preview_like']['count'];
            $userName = $edges['edges'][$i]['node']['owner']['username'];
        }

        $endCursor = $edges['page_info']['end_cursor'];
        $hasNextPage = $edges['page_info']['has_next_page'];
        $mediaCount = $edges['count'];
    }

    echo $followersCount . '<br>';
    echo $totalLikeCount . '<br>';
    echo $totalCommentCount . '<br>';
    echo ($totalLikeCount + $totalCommentCount) . '<br>';
    echo $userName . '<br>';
    echo $userId . '<br>';
    echo $mediaCount . '<br>';

    $percent = ($totalLikeCount + $totalCommentCount) / $followersCount * 100;
    echo "engagementRate: " . number_format($percent, 2, ',', '.') . '%';

I believe the big problem here is the number of HTTP requests you are doing. I think you must increase the number per request. It will decrease HTTP requests and probably speedup your code.

You set it on $count = 12;

I refactor your code and put $maxPerPage = 50 and tried to decrease some unnecessary counting and call for method $response->json().

    $headers = [
        'cookie' => 'sessionid=1796659686%3A4Ojj1py72bZKql%3A7; csrftoken=fPYrPRD1vHB7LdS0DjKzOK4kGo4uYK9f; ds_user_id=1796659686; ig_did=25114CCD-7A9D-4971-88F1-1E04796D9F14; ig_nrcb=1; mid=YiqZZQALAAEhkff6N5T2oovGOBkz; rur=01f73b7ee19feca3df296fc45ee75179c49dd54efb93233307b58f19bf707fea5d458fe7; shbid=01f7998eadf528233f0e7331b327e5a107134084c64e229af2cc6577b8a2ce862e3798da; shbts=01f7caf607a6877ca8407e9cb85cd175736a87f8f75e9076d5bddb32cbcbac6d5da45e89',
        'x-ig-app-id' => '936619743392459',
        'Content-Type' => 'application/json',
    ];
    $response = Http::withHeaders($headers)->get('https://www.instagram.com/elmaligroup/?__a=1');
    $response = $response->json();

    $userId = $response['graphql']['user']['id'];
    $followersCount = $response['graphql']['user']['edge_followed_by']['count'];
    $maxPerPage = 50;
    $endCursor = '';
    $hasNextPage = true;
    $totalLikeCount = 0;
    $totalCommentCount = 0;
    $userName = '';
    $mediaCount = 0;

    while ($hasNextPage) {

        $variables = urlencode(json_encode([
            "id" => $userId,
            "after" => $endCursor,
            "first" => $maxPerPage,
        ]));

        $response = Http::withHeaders($headers)->get('https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables=' . $variables);


        $edges = $response->json()['data']['user']['edge_owner_to_timeline_media'];
        $totalOfEdges = count($edges['edges']);

        for ($i = 0; $i < $totalOfEdges; $i++) {
            $totalCommentCount += $edges['edges'][$i]['node']['edge_media_to_comment']['count'];
            $totalLikeCount += $edges['edges'][$i]['node']['edge_media_preview_like']['count'];
            $userName = $edges['edges'][$i]['node']['owner']['username'];
        }

        $endCursor = $edges['page_info']['end_cursor'];
        $hasNextPage = $edges['page_info']['has_next_page'];
        $mediaCount = $edges['count'];
    }

    echo $followersCount . '<br>';
    echo $totalLikeCount . '<br>';
    echo $totalCommentCount . '<br>';
    echo ($totalLikeCount + $totalCommentCount) . '<br>';
    echo $userName . '<br>';
    echo $userId . '<br>';
    echo $mediaCount . '<br>';

    $percent = ($totalLikeCount + $totalCommentCount) / $followersCount * 100;
    echo "engagementRate: " . number_format($percent, 2, ',', '.') . '%';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文