Android 无法通过 RichRelevance SDK 获得所需的推荐产品

Not able to get the required recommended product through RichRelevance SDK for Android

Utils.GuestUserID=sharedPref.getSharedPref(getResources().getString(R.string.guest_user)); ClientConfiguration clientConfiguration=new ClientConfiguration("hjsd767443","gdfg63476473"); clientConfiguration.setUserId(Utils.GuestUserID); clientConfiguration.setSessionId(UUID.randomUUID().toString()); RichRelevance.init(这个,clientConfiguration);

    RichRelevance.setLoggingLevel(RRLog.VERBOSE);

    PlacementsRecommendationsBuilder placementsRecommendationsBuilder=new PlacementsRecommendationsBuilder();
    placementsRecommendationsBuilder.setProductIds(IDProduct);

    Placement placement = new Placement(Placement.PlacementType.ITEM, "Item page.recs_1mw");
    RichRelevance.buildRecommendationsForPlacements(placement)
            // Attach a callback
            .setCallback(new Callback<PlacementResponseInfo>() {
                @Override
                public void onResult(PlacementResponseInfo result) {
                    PlacementResponse placement = result.getPlacements().get(0);
                    RecommendedProduct product = placement.getRecommendedProducts().get(0);

                    product.trackClick();
                }

                @Override
                public void onError(com.richrelevance.Error error) {
                    Log.e(getClass().getSimpleName(), "Error: " + error.getMessage());
                }
            })
                    // Execute the request
            .execute();

我认为您的问题出在展示位置设置中:

Placement placement = new Placement(Placement.PlacementType.ITEM, "Item page.recs_1mw");

应该变成

Placement placement = new Placement(Placement.PlacementType.ITEM, "recs_1mw");

因为您已经在第一个参数中指定了 PageType/PlacementType。

Utils.GuestUserID=sharedPref.getSharedPref(getResources().getString(R.string.guest_user)); com.richrelevance.ClientConfiguration clientConfiguration=new com.richrelevance.ClientConfiguration("gdhg76476437gh","hfdjj627642547"); clientConfiguration.setUserId(Utils.GuestUserID); clientConfiguration.setSessionId(UUID.randomUUID().toString()); clientConfiguration.setEndpoint(Endpoints.PRODUCTION, 真); RichRelevance.init(这个,客户端配置); 展示位置 placement = new Placement(Placement.PlacementType.ITEM, "recs_1mw"); PlacementsRecommendationsBuilder placementsRecommendationsBuilder=new PlacementsRecommendationsBuilder(); placementsRecommendationsBuilder.setPlacements(放置); placementsRecommendationsBuilder.setProductIds(IDProduct);

    placementsRecommendationsBuilder.setCallback(new Callback<PlacementResponseInfo>() {
        @Override
        public void onResult(PlacementResponseInfo placementResponseInfo) {
            PlacementResponse placement = placementResponseInfo.getPlacements().get(0);
            Log.e("placement rich:",placement.toString());
            RecommendedProduct product = placement.getRecommendedProducts().get(0);
        }

        @Override
        public void onError(Error error) {

        }
    }).execute();