Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Schedule job to refresh a remote json file?

$
0
0

Hi

I am doing an app which via api uses information from an event system. The informtion comes in XML and I am converting it to json when a remote php file is called upon via Ti.Network.createHTTPClient in the app.

The data is gigantic and much more than I need in the app. Handling all data makes the app really slow.

Is there a way to set up a scheduled job, cron, running maybe once an hour, that pulls out what I need from the main data, populates a php file that I then can refer to from Ti.Network.createHTTPClient in the app?

This is a sample of how one single object looks like (sorry for the length of this....):

[  
   {  
      "Id":658510,
      "SystemName":"Event name",
      "TrackingPixelUrl":"url to tracking img",
      "UrlName":"an_url_name",
      "Name":"Name of event",
      "ForeignProductId":114007,
      "PackageId":null,
      "ProductReference":"ptg:114007",
      "OrganizationId":1045,
      "Version":473,
      "TemplateId":81,
      "Image":{  
         "MediaId":23040560,
         "MediaType":"Image",
         "Url":"url to image",
         "Width":595,
         "Height":709,
         "ProducedBy":"",
         "CopyrightBy":"",
         "ImageType":"Image"
      },
      "Status":"Active",
      "PublishedDate":"2014-10-30T23:04:48.79",
      "RevisionDate":null,
      "ExpirationDate":"2014-11-30T00:00:00",
      "Relevance":"None",
      "ParentProductId":null,
      "ProductType":"Product",
      "IsHighlight":false,
      "Attributes":{  
         "AttributeData":[  
            {  
               "Id":31557994,
               "AttributeId":99,
               "MetaType":"String",
               "Value":{  
                  "Data":"Name of event"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":361,
               "Language":1
            },
            {  
               "Id":31557995,
               "AttributeId":101,
               "MetaType":"String",
               "Value":{  
                  "Data":"A LOT of text"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":310,
               "Language":1
            },
            {  
               "Id":31557996,
               "AttributeId":102,
               "MetaType":"String",
               "Value":{  
                  "Data":"A lot of text"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":310,
               "Language":1
            },
            {  
               "Id":33270805,
               "AttributeId":106,
               "MetaType":"String",
               "Value":{  
                  "Data":"Entr\u00e9"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":1,
               "Language":1
            },
            {  
               "Id":33270808,
               "AttributeId":125,
               "MetaType":"String",
               "Value":{  
                  "Data":"url to arena"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":1,
               "Language":1
            },
            {  
               "Id":31557992,
               "AttributeId":115,
               "MetaType":"Media",
               "Value":{  
                  "MediaList":{  
                     "MediaObject":[  
                        {  
                           "MediaId":23040560,
                           "MediaType":"Image",
                           "Url":"url to picture",
                           "Width":595,
                           "Height":709,
                           "ProducedBy":"",
                           "CopyrightBy":"",
                           "ImageType":"Image"
                        },
                        {  
                           "MediaId":39904155,
                           "MediaType":"Image",
                           "Url":"url to picture",
                           "Width":595,
                           "Height":709,
                           "ProducedBy":"",
                           "CopyrightBy":"",
                           "ImageType":"Image"
                        }
                     ]
                  }
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":310,
               "Language":0
            },
            {  
               "Id":33270807,
               "AttributeId":145,
               "MetaType":"String",
               "Value":{  
                  "Data":"tele number"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":1,
               "Language":0
            },
            {  
               "Id":33270806,
               "AttributeId":147,
               "MetaType":"String",
               "Value":{  
                  "Data":"+46"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":1,
               "Language":0
            },
            {  
               "Id":33270810,
               "AttributeId":418,
               "MetaType":"MultiAttribute",
               "Value":{  
                  "Values":{  
                     "MultiAttributeObject":[  
                        {  
                           "Id":0,
                           "AttributeId":418,
                           "ProductId":658510,
                           "OrganizationId":1045,
                           "MultiAttributeId":631,
                           "MetaType":"Boolean",
                           "Value":{  
                              "Data":false
                           },
                           "Language":0
                        },
 
        This goes on and on - I had to cut it down to get it accepted by the Forum
        ]
As you see, there is a lot of non useful stuff there. I would like it to be more like:
[  
   {  
      "Id":658510,
      "Name":"Name of event",
      "OrganizationId":1045,
      "Image":{  
         "MediaId":23040560,
         "MediaType":"Image",
         "Url":"url to image",
         "Width":595,
         "Height":709,
      },
      "Status":"Active",
      "Attributes":{  
         "AttributeData":[  
            {  
               "Id":31557994,
               "AttributeId":99,
               "MetaType":"String",
               "Value":{  
                  "Data":"Name of event"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":361,
               "Language":1
            },
            {  
               "Id":31557995,
               "AttributeId":101,
               "MetaType":"String",
               "Value":{  
                  "Data":"A LOT of text"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":310,
               "Language":1
            },
            {  
               "Id":33270805,
               "AttributeId":106,
               "MetaType":"String",
               "Value":{  
                  "Data":"Entr\u00e9"
               },
            {  
               "Id":33270808,
               "AttributeId":125,
               "MetaType":"String",
               "Value":{  
                  "Data":"url to arena"
               },
            {  
               "Id":31557992,
               "AttributeId":115,
               "MetaType":"Media",
               "Value":{  
                  "MediaList":{  
                     "MediaObject":[  
                        {  
                           "MediaId":23040560,
                           "MediaType":"Image",
                           "Url":"url to picture",
                           "Width":595,
                           "Height":709,
                           "ProducedBy":"",
                           "CopyrightBy":"",
                           "ImageType":"Image"
                        },
                     ]
                  }
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":310,
               "Language":0
            },
            {  
               "Id":33270807,
               "AttributeId":145,
               "MetaType":"String",
               "Value":{  
                  "Data":"tele number"
               },
            {  
               "Id":33427942,
               "AttributeId":672,
               "MetaType":"String",
               "Value":{  
                  "Data":"80 min"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":43,
               "Language":0
            },
            {  
               "Id":33281252,
               "AttributeId":679,
               "MetaType":"String",
               "Value":{  
                  "Data":"xxx"
               },
               "ProductId":658510,
               "OrganizationId":1045,
               "Version":195,
               "Language":0
            }
         ]
      },
      "Occasions":{  
         "OccasionObject":{  
            "Id":19818466,
            "AttributeId":111,
            "ProductId":658510,
            "OrganizationId":1045,
            "StartDate":"2014-11-29T00:00:00",
            "EndDate":"2014-11-29T00:00:00",
            "StartTime":"0001-01-01T19:30:00",
            "EndTime":"0001-01-01T21:30:00",
            "ValidDays":"Saturday",
            "ArenaId":563411,
            "ArenaName":"xxx",
            "EntryTime":"0001-01-01T00:00:00"
         }
      }
]
( I only need an event name, phone number, link to event url to image and a couple of other stuff)

So - is there a way to refer to a shorter, automatically generated php file, holding a shorter json like the one in the bottom of this page, on my server?

I am so lost in this matter - help is gladly appreciated!

Best regards /Tove


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>