Here API: Getting wrong transit route information using the Android sdk - here-api

I try to fetch a basic transit route using the Android sdk but I'm missing data I need.
Basically, I want to get the exact same data as the Here We Go planner. Where you can see the steps, their departure and arrival time, which type of transit and which platform it departs or arrives.
So when I try to use RoutePlan in the Android sdk it gives me a wrong tta, it's like an hour longer than what it should be without any additional steps so far I can see. It also does not show the platforms and departure/arrival times of steps. The same applies for sending a route request to the route api in Postman.
My question is, how can I retrieve the exact same data as the Here We Go planner and app using the Android sdk?
Update: my Here project page also says 'Estimated Public Transit' for the majority of my requests, is this how it is supposed to be or should this be something else?
Update 2: I have tried using the here we go maps 1, postman [code below] and android sdk [code below] for the same route and got very different results.
Postman request: https://route.api.here.com/routing/7.2/calculateroute.json?app_id=app_id&app_code=app_code&waypoint0=52.3146653,5.0248838&waypoint1=52.6381,4.740599999999972&departure=now&mode=fastest;publicTransport&combineChange=true
With result:
{
"response": {
"metaInfo": {
"timestamp": "2019-06-18T07:59:29Z",
"mapVersion": "8.30.97.151",
"moduleVersion": "7.2.201923-3839",
"interfaceVersion": "2.6.58",
"availableMapVersion": [
"8.30.97.151"
]
},
"route": [
{
"waypoint": [
{
"linkId": "-54239714",
"mappedPosition": {
"latitude": 52.3146951,
"longitude": 5.0248396
},
"originalPosition": {
"latitude": 52.3146653,
"longitude": 5.0248837
},
"type": "stopOver",
"spot": 1,
"sideOfStreet": "left",
"mappedRoadName": "Pampuslaan",
"label": "Pampuslaan",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "-1208098680",
"mappedPosition": {
"latitude": 52.6384828,
"longitude": 4.740455
},
"originalPosition": {
"latitude": 52.6381,
"longitude": 4.7406
},
"type": "stopOver",
"spot": 0.247191,
"sideOfStreet": "left",
"mappedRoadName": "Kruseman van Eltenweg",
"label": "Kruseman van Eltenweg",
"shapeIndex": 288,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"publicTransport"
],
"trafficMode": "disabled",
"feature": []
},
"leg": [
{
"start": {
"linkId": "-54239714",
"mappedPosition": {
"latitude": 52.3146951,
"longitude": 5.0248396
},
"originalPosition": {
"latitude": 52.3146653,
"longitude": 5.0248837
},
"type": "stopOver",
"spot": 1,
"sideOfStreet": "left",
"mappedRoadName": "Pampuslaan",
"label": "Pampuslaan",
"shapeIndex": 0,
"source": "user"
},
"end": {
"linkId": "-1208098680",
"mappedPosition": {
"latitude": 52.6384828,
"longitude": 4.740455
},
"originalPosition": {
"latitude": 52.6381,
"longitude": 4.7406
},
"type": "stopOver",
"spot": 0.247191,
"sideOfStreet": "left",
"mappedRoadName": "Kruseman van Eltenweg",
"label": "Kruseman van Eltenweg",
"shapeIndex": 288,
"source": "user"
},
"length": 57000,
"travelTime": 7637,
"maneuver": [
{
"position": {
"latitude": 52.3146951,
"longitude": 5.0248396
},
"instruction": "Head <span class=\"heading\">south</span> on <span class=\"street\">Pampuslaan</span>. <span class=\"distance-description\">Go for <span class=\"length\">99 m</span>.</span>",
"travelTime": 109,
"length": 99,
"id": "M1",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3138046,
"longitude": 5.024904
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Gemeenschapspolderweg</span>. <span class=\"distance-description\">Go for <span class=\"length\">887 m</span>.</span>",
"travelTime": 912,
"length": 887,
"id": "M2",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3131716,
"longitude": 5.0369418
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Jan Campertplein</span>. <span class=\"distance-description\">Go for <span class=\"length\">98 m</span>.</span>",
"travelTime": 110,
"length": 98,
"id": "M3",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3137081,
"longitude": 5.0380576
},
"instruction": "Turn <span class=\"direction\">right</span> onto <span class=\"next-street\">E. du Perronstraat</span>. <span class=\"distance-description\">Go for <span class=\"length\">338 m</span>.</span>",
"travelTime": 349,
"length": 338,
"id": "M4",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3127103,
"longitude": 5.0419629
},
"instruction": "Turn <span class=\"direction\">right</span> onto <span class=\"next-street\">Stationsplein</span>. <span class=\"distance-description\">Go for <span class=\"length\">21 m</span>.</span>",
"travelTime": 32,
"length": 21,
"id": "M5",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.3125601,
"longitude": 5.0421453
},
"instruction": "Turn <span class=\"direction\">left</span>. <span class=\"distance-description\">Go for <span class=\"length\">133 m</span>.</span>",
"travelTime": 133,
"length": 133,
"id": "M6",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.312485,
"longitude": 5.0435722
},
"instruction": "Go to the station <span class=\"station\">Weesp</span> and take the <span class=\"transit\">train</span> <span class=\"line\">Sprinter</span> toward <span class=\"destination\">Amsterdam Centraal</span>. <span class=\"distance-description\">Follow for <span class=\"stops\">4 stations</span>.</span>",
"travelTime": 1915,
"length": 13021,
"id": "M7",
"stopName": "Weesp",
"_type": "PublicTransportManeuverType"
},
{
"position": {
"latitude": 52.3787248,
"longitude": 4.9008143
},
"instruction": "Get off at <span class=\"station\">Amsterdam Centraal</span> and change to the <span class=\"transit\">train</span> <span class=\"line\">Intercity</span> toward <span class=\"destination\">Alkmaar</span>. <span class=\"distance-description\">Follow for <span class=\"stops\">4 stations</span>.</span>",
"travelTime": 3095,
"length": 41444,
"id": "M8",
"stopName": "Amsterdam Centraal",
"_type": "PublicTransportManeuverType"
},
{
"position": {
"latitude": 52.6377726,
"longitude": 4.7408044
},
"instruction": "Get off at <span class=\"station\">Alkmaar</span>.",
"travelTime": 0,
"length": 0,
"id": "M9",
"stopName": "Alkmaar",
"_type": "PublicTransportManeuverType"
},
{
"position": {
"latitude": 52.6377726,
"longitude": 4.7408044
},
"instruction": "Head <span class=\"heading\">southeast</span>. <span class=\"distance-description\">Go for <span class=\"length\">367 m</span>.</span>",
"travelTime": 378,
"length": 367,
"id": "M10",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.637794,
"longitude": 4.7458577
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Helderseweg</span>. <span class=\"distance-description\">Go for <span class=\"length\">208 m</span>.</span>",
"travelTime": 217,
"length": 208,
"id": "M11",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.6396501,
"longitude": 4.7454929
},
"instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Kruseman van Eltenweg</span>. <span class=\"distance-description\">Go for <span class=\"length\">384 m</span>.</span>",
"travelTime": 387,
"length": 384,
"id": "M12",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 52.6384828,
"longitude": 4.740455
},
"instruction": "Arrive at <span class=\"street\">Kruseman van Eltenweg</span>. Your destination is on the left.",
"travelTime": 0,
"length": 0,
"id": "M13",
"_type": "PrivateTransportManeuverType"
}
]
}
],
"publicTransportLine": [
{
"lineName": "Sprinter",
"companyName": "",
"destination": "Amsterdam Centraal",
"type": "trainRegional",
"id": "L1"
},
{
"lineName": "Intercity",
"companyName": "",
"destination": "Alkmaar",
"type": "trainRegional",
"id": "L2"
}
],
"summary": {
"distance": 57000,
"baseTime": 7637,
"flags": [
"noThroughRoad",
"builtUpArea",
"privateRoad"
],
"text": "The trip takes <span class=\"length\">57.0 km</span> and <span class=\"time\">2:07 h</span>.",
"travelTime": 7637,
"departure": "2019-06-18T09:59:29+02:00",
"_type": "PublicTransportRouteSummaryType"
}
}
],
"language": "en-us"
}
}
Logging the departure time and duration of the route in Android resulted in:
I/Departure time: 10:00
I/Duration: 02:51
Using the following code snippets:
Planning:
RoutePlan routePlan = new RoutePlan();
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.PUBLIC_TRANSPORT);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routeOptions.setRouteCount(3);
routeOptions.setLocale(Locale.getDefault());
if (toggleSwitch.getCheckedTogglePosition() == 0) {
routeOptions.setTime(selected_time, RouteOptions.TimeType.DEPARTURE);
}
else {
// Arrival time
}
routePlan.setRouteOptions(routeOptions);
// Select Waypoints for your routes
routePlan.addWaypoint(new RouteWaypoint(start_address_coordinate));
routePlan.addWaypoint(new RouteWaypoint(end_address_coordinate));
router.calculateRoute(routePlan, new RouterListener());
Result listener:
private final class RouterListener implements CoreRouter.Listener {
// Method defined in Listener
public void onProgress(int percentage) {
// Display a message indicating calculation progress
}
// Method defined in Listener
public void onCalculateRouteFinished(List<RouteResult> routeResult, RoutingError error) {
// If the route was calculated successfully
if (error == RoutingError.NONE) {
progressBar.setVisibility(View.GONE);
planButton.setEnabled(true);
Long start_time = routeResult.get(0).getRoute().getManeuvers().get(0).getStartTime().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault());
String start_date = sdf.format(new Date(start_time));
Date duration = new Date(routeResult.get(0).getRoute().getTtaIncludingTraffic(Route.WHOLE_ROUTE).getDuration() * 1000);
Log.i("Departure time", start_date);
Log.i("Duration", sdf.format(duration));
}
else {
// Display a message indicating route calculation failure
Log.e("Route Calculation ERROR", error.toString());
}
}
}

According the documentation on PT of HERE Routing API:
The Routing API calculates public transport routes in one of two ways:
Estimated Routing – uses aggregated data to estimate a route.
Timetable Routing – uses dynamic data to provide a more precise,
detailed route.
How is deference of both above you can play on http://refclient.ext.here.com/
According the documentation for Android mSDK you can calculate transit routes using known online timetable information but this feature SDK-Route-PT-Timetable doesn't enabled for Freemium account(still not in the documentation yet, sorry for that) therefore for Freemium credentials will be used Estimated Routing(not Timetable Routing) and results will be corresponded to results of Routing API Estimated Routing for Public Transport.(Keep in mind for Routing API set please departure time parameter otherwise should be used TimeTable by default for calculation)
if you want to have the feature SDK-Route-PT-Timetable in your mSDK then contact us for more details on:
Service Support
Contact to HERE

Related

Nextjs 13 displaying an Image

I am using the experimental app version of Nextjs 13.
My next.config.js looks like this:
/** #type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
images: {
remotePatterns: [
{
protocol: 'http',
hostname: '127.0.0.1',
port: '1337',
pathname: '/api/**',
},
],
},
};
module.exports = nextConfig;
I make the following call to display an image on the screen:
<Image className='mt-2'
src={movie.data.attributes.image.data.attributes.url}
alt={movie.data.attributes.title}
width={500}
height={350}
/>
</div>
On the server side I am getting the following response:
The requested resource isn't a valid image for /uploads/2008_Jaden_3c49c0fe45.jpg received text/html; charset=utf-8
The image name is correct. And the title displayed is also correct.
It seems that the system is still pointing to the local folder /uploads instead of to the remote host that I configured in the next.config.js file.
I have tried and changed many things but I am unable to display the images. Hopefully someone can help me out?
Robert
I am using the following version:
Next.js 13.1.6
React 18.0.27
And for my backend
Strapi 4.6.1
The Strapi API route looks like this:
// 20230217152302
// http://127.0.0.1:1337/api/movies?populate=*
{
"data": [
{
"id": 1,
"attributes": {
"createdAt": "2023-02-03T15:39:55.796Z",
"updatedAt": "2023-02-07T11:39:47.652Z",
"publishedAt": "2023-02-03T15:40:08.569Z",
"title": "Lord of the Rings",
"year": 2001,
"description": "A meek Hobbit from the Shire and eight companions set out on a journey to destroy the powerful One Ring and save Middle-earth from the Dark Lord Sauron",
"slug": "lord-of-the-rings",
"image": {
"data": {
"id": 3,
"attributes": {
"name": "6FDUBGB.jpg",
"alternativeText": null,
"caption": null,
"width": 2000,
"height": 2496,
"formats": {
"thumbnail": {
"name": "thumbnail_6FDUBGB.jpg",
"hash": "thumbnail_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 125,
"height": 156,
"size": 8.49,
"url": "/uploads/thumbnail_6_FDUBGB_f8b45dbbae.jpg"
},
"small": {
"name": "small_6FDUBGB.jpg",
"hash": "small_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 401,
"height": 500,
"size": 62.75,
"url": "/uploads/small_6_FDUBGB_f8b45dbbae.jpg"
},
"medium": {
"name": "medium_6FDUBGB.jpg",
"hash": "medium_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 601,
"height": 750,
"size": 117.55,
"url": "/uploads/medium_6_FDUBGB_f8b45dbbae.jpg"
},
"large": {
"name": "large_6FDUBGB.jpg",
"hash": "large_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 801,
"height": 1000,
"size": 182.81,
"url": "/uploads/large_6_FDUBGB_f8b45dbbae.jpg"
}
},
"hash": "6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"size": 597.08,
"url": "/uploads/6_FDUBGB_f8b45dbbae.jpg",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"createdAt": "2023-02-07T11:39:40.120Z",
"updatedAt": "2023-02-07T11:39:40.120Z"
}
}
}
}
},
{
"id": 2,
"attributes": {
"createdAt": "2023-02-03T15:42:51.349Z",
"updatedAt": "2023-02-07T11:40:12.979Z",
"publishedAt": "2023-02-03T15:42:52.112Z",
"title": "Star Wars",
"year": 1977,
"description": "Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a Wookiee and two droide to save the galaxy from the Empire's wold-destroying battle station, while also attemting te rescue Princess Leia from the mysterious Darth Vader.",
"slug": "star-wars",
"image": {
"data": {
"id": 4,
"attributes": {
"name": "2008 Jaden.jpg",
"alternativeText": null,
"caption": null,
"width": 1868,
"height": 1304,
"formats": {
"thumbnail": {
"name": "thumbnail_2008 Jaden.jpg",
"hash": "thumbnail_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 223,
"height": 156,
"size": 9.92,
"url": "/uploads/thumbnail_2008_Jaden_3c49c0fe45.jpg"
},
"small": {
"name": "small_2008 Jaden.jpg",
"hash": "small_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 500,
"height": 349,
"size": 35.21,
"url": "/uploads/small_2008_Jaden_3c49c0fe45.jpg"
},
"medium": {
"name": "medium_2008 Jaden.jpg",
"hash": "medium_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 750,
"height": 524,
"size": 65.83,
"url": "/uploads/medium_2008_Jaden_3c49c0fe45.jpg"
},
"large": {
"name": "large_2008 Jaden.jpg",
"hash": "large_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 1000,
"height": 698,
"size": 102.08,
"url": "/uploads/large_2008_Jaden_3c49c0fe45.jpg"
}
},
"hash": "2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"size": 258.7,
"url": "/uploads/2008_Jaden_3c49c0fe45.jpg",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"createdAt": "2023-02-07T11:40:06.583Z",
"updatedAt": "2023-02-07T11:40:06.583Z"
}
}
}
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 2
}
}
}

Strapi 4.6 back-end with Nextjs 13 as front-end

How can I get the image stored in Strapi 4.6 displayed on the screen with nextjs 13:
export default function Page({ params }) {
let movie = use(getMovie(params.movieID));
console.log("Movie This is the text", movie);
//console.log(params.movieID);
//console.log("Database output !!!", movie.${params.movieID}.?populate=*);
//const API_URL = ('http://127.0.0.1:1337');
return (
<div>
<p className="text-3xl">{movie.data.attributes.title}</p>
<p className="mt-2">Year: {movie.data.attributes.year}</p>
<p className="mt-2">Description: {movie.data.attributes.description}</p>
<Image className='mt-2'
src={movie.data.attributes.image.data.attributes.url}
alt={movie.data.attributes.title}
width={500}
height={349}
/>
</div>
);
}
The Title, year, and description of the movie are fixable on the screen.
On de server side I am receiving the following error:
event - compiled client and server successfully in 145 ms (545 modules)
The requested resource isn't a valid image for /uploads/2008_Jaden_3c49c0fe45.jpg received text/html; charset=utf-8
The settings of my next.config.js file are:
/** #type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
images: {
remotePatterns: [
{
protocol: "http",
hostname: "127.0.0.1",
port: "1337",
pathname: "/**",
},
],
},
};
module.exports = nextConfig;
Strapi 4.6 return the following API:
// 20230217152302
// http://127.0.0.1:1337/api/movies?populate=*
{
"data": [
{
"id": 1,
"attributes": {
"createdAt": "2023-02-03T15:39:55.796Z",
"updatedAt": "2023-02-07T11:39:47.652Z",
"publishedAt": "2023-02-03T15:40:08.569Z",
"title": "Lord of the Rings",
"year": 2001,
"description": "A meek Hobbit from the Shire and eight companions set out on a journey to destroy the powerful One Ring and save Middle-earth from the Dark Lord Sauron",
"slug": "lord-of-the-rings",
"image": {
"data": {
"id": 3,
"attributes": {
"name": "6FDUBGB.jpg",
"alternativeText": null,
"caption": null,
"width": 2000,
"height": 2496,
"formats": {
"thumbnail": {
"name": "thumbnail_6FDUBGB.jpg",
"hash": "thumbnail_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 125,
"height": 156,
"size": 8.49,
"url": "/uploads/thumbnail_6_FDUBGB_f8b45dbbae.jpg"
},
"small": {
"name": "small_6FDUBGB.jpg",
"hash": "small_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 401,
"height": 500,
"size": 62.75,
"url": "/uploads/small_6_FDUBGB_f8b45dbbae.jpg"
},
"medium": {
"name": "medium_6FDUBGB.jpg",
"hash": "medium_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 601,
"height": 750,
"size": 117.55,
"url": "/uploads/medium_6_FDUBGB_f8b45dbbae.jpg"
},
"large": {
"name": "large_6FDUBGB.jpg",
"hash": "large_6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 801,
"height": 1000,
"size": 182.81,
"url": "/uploads/large_6_FDUBGB_f8b45dbbae.jpg"
}
},
"hash": "6_FDUBGB_f8b45dbbae",
"ext": ".jpg",
"mime": "image/jpeg",
"size": 597.08,
"url": "/uploads/6_FDUBGB_f8b45dbbae.jpg",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"createdAt": "2023-02-07T11:39:40.120Z",
"updatedAt": "2023-02-07T11:39:40.120Z"
}
}
}
}
},
{
"id": 2,
"attributes": {
"createdAt": "2023-02-03T15:42:51.349Z",
"updatedAt": "2023-02-07T11:40:12.979Z",
"publishedAt": "2023-02-03T15:42:52.112Z",
"title": "Star Wars",
"year": 1977,
"description": "Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a Wookiee and two droide to save the galaxy from the Empire's wold-destroying battle station, while also attemting te rescue Princess Leia from the mysterious Darth Vader.",
"slug": "star-wars",
"image": {
"data": {
"id": 4,
"attributes": {
"name": "2008 Jaden.jpg",
"alternativeText": null,
"caption": null,
"width": 1868,
"height": 1304,
"formats": {
"thumbnail": {
"name": "thumbnail_2008 Jaden.jpg",
"hash": "thumbnail_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 223,
"height": 156,
"size": 9.92,
"url": "/uploads/thumbnail_2008_Jaden_3c49c0fe45.jpg"
},
"small": {
"name": "small_2008 Jaden.jpg",
"hash": "small_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 500,
"height": 349,
"size": 35.21,
"url": "/uploads/small_2008_Jaden_3c49c0fe45.jpg"
},
"medium": {
"name": "medium_2008 Jaden.jpg",
"hash": "medium_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 750,
"height": 524,
"size": 65.83,
"url": "/uploads/medium_2008_Jaden_3c49c0fe45.jpg"
},
"large": {
"name": "large_2008 Jaden.jpg",
"hash": "large_2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"path": null,
"width": 1000,
"height": 698,
"size": 102.08,
"url": "/uploads/large_2008_Jaden_3c49c0fe45.jpg"
}
},
"hash": "2008_Jaden_3c49c0fe45",
"ext": ".jpg",
"mime": "image/jpeg",
"size": 258.7,
"url": "/uploads/2008_Jaden_3c49c0fe45.jpg",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"createdAt": "2023-02-07T11:40:06.583Z",
"updatedAt": "2023-02-07T11:40:06.583Z"
}
}
}
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 2
}
}
}
Hopefully someone can help me out?
Thanks on forehand for your help!
Robert
Strapi only returns the relative paths of your images (or media in general). You need to prepend those paths with the URL/domain on which your Strapi is hosted.
E.g:
"http://127.0.0.1:1337" + "/uploads/2008_Jaden_3c49c0fe45.jpg"
"https://my-hosted-strapi.com" + "/uploads/2008_Jaden_3c49c0fe45.jpg"

How to Get County Information for the given address when we use Rest API

I am using below code to get the address information and i am getting entire address. But i only need county for the given city and zip of USA. Please help
function getCounty()
{
$.ajax({
url: 'https://geocoder.api.here.com/6.2/geocode.json',
type: 'GET',
dataType: 'jsonp',
jsonp: 'jsoncallback',
data: {
city: 'Farmington',
postalcode: '48335',
country: 'usa',
app_id: '**************************',
app_code: '************************',
gen: '9'
},
success: function (data) {
alert(JSON.stringify(data));
}
});
}
Please try below code to access County attribute of the response.
Hope this help.
alert(data.Response.View[0].Result[0].Location.Address.County);
And please check below full JSON response for the request.
{
"Response": {
"MetaInfo": {
"Timestamp": "2019-01-09T07:08:18.912+0000"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1,
"MatchLevel": "postalCode",
"MatchQuality": {
"City": 1,
"PostalCode": 1
},
"Location": {
"LocationId": "NT_9usvaftBv-o9T6WyVpnWRC",
"LocationType": "area",
"DisplayPosition": {
"Latitude": 42.47427,
"Longitude": -83.40889
},
"NavigationPosition": [
{
"Latitude": 42.47427,
"Longitude": -83.40889
}
],
"MapView": {
"TopLeft": {
"Latitude": 42.48732,
"Longitude": -83.4355
},
"BottomRight": {
"Latitude": 42.43954,
"Longitude": -83.37537
}
},
"Address": {
"Label": "48335, Farmington, MI, United States",
"Country": "USA",
"State": "MI",
"County": "Oakland",
"City": "Farmington",
"PostalCode": "48335",
"AdditionalData": [
{
"value": "United States",
"key": "CountryName"
},
{
"value": "Michigan",
"key": "StateName"
},
{
"value": "Oakland",
"key": "CountyName"
},
{
"value": "N",
"key": "PostalCodeType"
}
]
}
}
}
]
}
]
}
}

Wordpress API V2 does not embed items when query parameter is passed

Per the documentation:
Optionally, some linked resources may be included in the response to
reduce the number of HTTP requests required. These resources are
“embedded” into the main response.
Embedding is triggered by setting the _embed query parameter on the
request. This will then include embedded resources under the _embedded
key adjacent to the _links key. The layout of this object mirrors the
_links object, but includes the embedded resource in place of the link
properties.
Despite this, when I make the following GET request:
http://anawins.com/wp-json/wp/v2/posts/2986?_embed
The resulting JSON is identical the request without ?_embed.
With embed:
{
"id": 2986,
"date": "2016-05-09T03:00:42",
"date_gmt": "2016-05-09T07:00:42",
"guid": {
"rendered": "http:\/\/anawins.com\/?p=2986"
},
"modified": "2016-05-08T16:37:39",
"modified_gmt": "2016-05-08T20:37:39",
"slug": "the-secret-to-speaking-with-more-grace",
"type": "post",
"link": "http:\/\/anawins.com\/the-secret-to-speaking-with-more-grace\/",
"title": {
"rendered": "The Secret to Speaking With Grace"
},
"content": {
"rendered": "<p><img class=\"aligncenter size-large wp-image-3474\" src=\"http:\/\/anawins.com\/wp-content\/uploads\/2016\/05\/the-secret-to-speaking-with-grace-367x550.png\" alt=\"Do you...."
},
"excerpt": {
"rendered": "<p>I have a little..."
},
"author": 2,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "standard",
"categories": [193, 58],
"tags": [110, 194, 206, 205, 204],
"better_featured_image": null,
"_links": {
"self": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986"
}],
"collection": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts"
}],
"about": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/types\/post"
}],
"author": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/users\/2"
}],
"replies": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/comments?post=2986"
}],
"version-history": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986\/revisions"
}],
"wp:attachment": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/media?parent=2986"
}],
"wp:term": [{
"taxonomy": "category",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/categories?post=2986"
}, {
"taxonomy": "post_tag",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/tags?post=2986"
}],
"curies": [{
"name": "wp",
"href": "https:\/\/api.w.org\/{rel}",
"templated": true
}]
}
}
Without _embed:
{
"id": 2986,
"date": "2016-05-09T03:00:42",
"date_gmt": "2016-05-09T07:00:42",
"guid": {
"rendered": "http:\/\/anawins.com\/?p=2986"
},
"modified": "2016-05-08T16:37:39",
"modified_gmt": "2016-05-08T20:37:39",
"slug": "the-secret-to-speaking-with-more-grace",
"type": "post",
"link": "http:\/\/anawins.com\/the-secret-to-speaking-with-more-grace\/",
"title": {
"rendered": "The Secret to Speaking With Grace"
},
"content": {
"rendered": "<p><img class=\"aligncenter size-large wp-image-3474\" src=\"http:\/\/anawins.com\/wp-content\/uploads\/2016\/05\/the-secret-to-speaking-with-grace-367x550.png\" alt=\"Do you struggle..."
},
"excerpt": {
"rendered": "<p>I have a little..."
},
"author": 2,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "standard",
"categories": [193, 58],
"tags": [110, 194, 206, 205, 204],
"better_featured_image": null,
"_links": {
"self": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986"
}],
"collection": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts"
}],
"about": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/types\/post"
}],
"author": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/users\/2"
}],
"replies": [{
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/comments?post=2986"
}],
"version-history": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/posts\/2986\/revisions"
}],
"wp:attachment": [{
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/media?parent=2986"
}],
"wp:term": [{
"taxonomy": "category",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/categories?post=2986"
}, {
"taxonomy": "post_tag",
"embeddable": true,
"href": "http:\/\/anawins.com\/wp-json\/wp\/v2\/tags?post=2986"
}],
"curies": [{
"name": "wp",
"href": "https:\/\/api.w.org\/{rel}",
"templated": true
}]
}
}
How do I change the query to make this work?

Open graph fitness.runs returning no data

I have a bunch of Nike+ run data which i'm assuming (based on the below article) is published to the open graph. It certainly looks that way in my timeline.
https://developers.facebook.com/blog/post/2012/08/29/early-success-stories--fitness-and-open-graph/
Frustratingly while my music.listens request works fine and returns all of my Spotify listens, my request for fitness.runs returns no data. Is this simply because Nike haven't integrated correctly with the Open Graph. Or perhaps I need to request extended permissions in my Auth token?
https://developers.facebook.com/docs/reference/opengraph/action-type/fitness.runs
Any ideas?
As with all actions you need the correct permissions, in this case
user_actions.fitness
So the data returned from /me/fitness.runs for Nike will look like
{
"data": [
{
"id": "10101118696330517",
"from": {
"name": "Philippe Harewood",
"id": "13608786"
},
"start_time": "2013-03-22T23:15:56+0000",
"end_time": "2013-03-22T23:26:36+0000",
"publish_time": "2013-03-24T15:50:00+0000",
"application": {
"name": "Nike",
"namespace": "nikeapp",
"id": "84697719333"
},
"data": {
"course": {
"id": "476811255725972",
"url": "http://nikeplus.nike.com/plus/activity/running/detail/2118587303?external_share_id=CE32E1C4-93D8-48A7-A08F-6D5B4C13EE6A&is_new_meta=true",
"type": "fitness.course",
"title": "1.12 miles"
}
},
"type": "fitness.runs",
"no_feed_story": false,
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
},
{
"id": "10101118696155867",
"from": {
"name": "Philippe Harewood",
"id": "13608786"
},
"start_time": "2013-03-19T22:03:32+0000",
"end_time": "2013-03-19T22:18:37+0000",
"publish_time": "2013-03-24T15:49:46+0000",
"application": {
"name": "Nike",
"namespace": "nikeapp",
"id": "84697719333"
},
"data": {
"course": {
"id": "502469216483599",
"url": "http://nikeplus.nike.com/plus/activity/running/detail/2118587302?external_share_id=EBF6BC1D-BDEA-4EE5-B18D-FBC576610F13&is_new_meta=true",
"type": "fitness.course",
"title": "1.49 miles"
}
},
"type": "fitness.runs",
"no_feed_story": false,
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
}
],
"paging": {
"next": "https://graph.facebook.com/13608786/fitness.runs?limit=25&offset=25&__after_id=10101118696155867"
}
}

Resources