paging via graph api? - facebook-graph-api

i have been working on a new app to display feeds posted from a certain app, which is working fine, however, it only shows 25 results and after that it shows a paging array like so:
[paging] => Array
(
[previous] => https://graph.facebook.com/100000229028365/home?method=GET&access_token=AAACOrxawWZCgBACwTDcb79QOtboPgAhLGLT4d31vkKEqQTVHgj91a6QGQ9mUFhdpScma4ZCdmpZB7HNnpGj0itAht4oVJqJLyIRMVy4VFnGfQ07WZCKz&limit=25&since=1321212154
[next] => https://graph.facebook.com/100000229028365/home?method=GET&access_token=AAACOrxawWZCgBACwTDcb79QOtboPgAhLGLT4d31vkKEqQTVHgj91a6QGQ9mUFhdpScma4ZCdmpZB7HNnpGj0itAht4oVJqJLyIRMVy4VFnGfQ07WZCKz&limit=25&until=1321209616
)
i have tried to implament this into my app without success.
can anyone show me an example how to use this to produce pagnation for my app?
pretty stuck now =os

Im pretty sure all you need to do is take the previous link and do a graph call with that to get the next 25, alternatively the less desirable method would be to change the limit when you do a graph call or if you dont use one when you do a call specify ?limit=100 and this will get 100 results

Related

How to specify "element(by.id" or "element(by.css" in Ember.js using Protractor

New to ember.js -- used http://yoember.com/ to create a Demo ember.js site. I'm trying to figure out how to use Protractor to test certain elements, but I'm encountering issues specifying them.
Most, but not all, elements (buttons, text areas, etc) have a serialized id value: id='ember###' that changes every time the page is reloaded, which makes it impossible to indicate some elements in Protractor (like, element(by.id('ember557')).sendKeys('foo');).
Running a command like the one above will return the error: Failed: No element found using locator: By(css selector, *[id="ember557"]), which is due to the 3-digit id value changing.
In my demo app, I was able to go into the /app/templates/components/ file for that page and manually add something like id='name' into the handlebars input and was able to successfully find and test that element in Protractor.
This isn't ideal though, and I'd like to find a way to test sites that I don't have the ability to modify the html of.
Can anyone help me wrap my head around this? Thanks.

RESTomancy: Getting products from category in Prestashop 1.5

Disclaimers:
This is oriented towards Prestashop 1.5 but if the answer is: "this
is fixed in version 1.x" then I'll raise a petition to update our
shop.
I'm also tagging it as REST because I think I explained it throughly
enough so you don't need actual experience with Prestashop to understand it.
So in Prestashop we have this Web Services which lack support for use cases as simple as search by category.
1. Let's say you want to get all the products from categories 1, 3 and 17:
So what is the solution?
Well, you can do something in the lines of this answer: https://stackoverflow.com/a/34061229/4209853
where you get all the products from categories 1, 3 and 17 and then you make another call for products filtering by those ID's.
'filter[id]' => '['.implode('|',$productIDsArrayIGotBefore).']',
it's ugly and 20th centurish, but well... if it gets the job done... except it doesn't.
You see, this is a call for getting a resource, and someone somewhere decided:
Hey, we have all this nice HTTP action verbs, so let's use them for REST CRUD interfaces: POST for C, GET for R, PUT for U and DELETE for D. Neat.
And that's nice and all, but when combined with the lack of expressive power of Prestashop's Web Services means it's stupidly easy to run into, you guessed it? Yes, 414.
Error HTTP 414 Request URI too long
and we all know that modifying Apache so it accepts longer request URIs is not the neat scalable solution.
So we could try to split the array and make multiple calls, which is just conceptually ugh. Not just because of the performance hit of making multiple queries, but also because we would need to take into account the number of characters of all IDs concatenated to make the calculation of how many we can (safely) ask for in one call. And all that would have their own caveats, like:
2. What if we want to also filter them e.g. active=1?
Now we're in for a ride, because we can't know beforehand how many calls we will need to make.
Let's define:
N are the IDs I got from categories
n is the number of IDS I can safely ask for
T is the number of (filtered) products I want
tare the (filtered) products I already have
k are the (filtered) products we receive from the call
So we would end up with something like:
do{
n0= max(T-t, n);
k= get(products, n0);
t +=k;
}while(count(k)!=0 and count(t)<T and !empty(N))
..which is just... bonkers.
The only elegant solution I can come up with is creating a new Prestashop Web Service that acts as a wrapper, receiving the petition through POST and forwarding it to the Prestashop service.
But, befores that... do you have a better solution using some kind of RESTomancy I may be missing?

How to get similar items with Amazon's Product Advertising API?

I have recently added an Amazon Search to my website and am having an issue getting the full response I need. In around 10% of my calls I get zero hits even though Amazon's site itself display numerous hits. Here is my call to their service:
results = Amazon::Ecs.item_search(query_text, {
:search_index => 'All',
:response_group => 'ItemAttributes, Images, Offers',
:item_page=>’1'
})
90% of the time the results I get back are just fine, but with any of the following query texts this search returns 0 hits:
hoover bag 440004496 type S
Citizen Women’s Stainless Steel Bracelet Watch 18mm EJ5850-57E
mope space pack iPhone 5
Yet when I go to Amazon.com directly and search on any of these targets I do get plenty of relevant responses.
What happens is Amazon displays, for instance, "Your search "hoover bag 440004496 type S" did not match any products" and then goes on to display "hoover bag 440004496 type S” See all 322 results…” and plenty of good, relevant product matches that I would love to display on my page.
You can see the results (or lack thereof) at my site, www.FastForward.menu
How do I get these helpful responses through the API? Preferably in the same format that any populated initial item_search response is in? Preferably in the same call as the initial response so I don’t have to write more parsing code?
There is a “Similar products” API call, but to do that you need at least one product to pass in, which I do not have. See here: http://docs.aws.amazon.com/AWSECommerceService/latest/DG/SimilarityLookup.html
How do I get this list of “similar” products through the API so that my Amazon searched don’t come up completely empty around 10% of the time?
I am sure others have run into this same question.
Please feel free to ask questions or to make suggestions as to how I can improve this question.

Load testing with SOAP UI

I have a SOAP UI 4.5.1, I have made a load test, it is working fine. My problem is that I run the same request every time and I need to change the values of the soap request I am sending.
For e.g. I have a block of my soap request:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
Provider ID: SHL
Project ID: SampleAssessment
Is there a way to make those values changing from some kind of interval?
For e.g.: Provider IDs [SHL, SLH, LHS]
Project IDs [SampleAssessment, TestAssessment, AnotherAssessment]
And with a load test I am making three request so that for the first request values looks like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
for the second like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SLH</ns:ProviderId>
<ns:ProjectId>TestAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
and so on...
Is there a way to make this happen with SOAP UI?
From my experience, you will need to use a Groovy Script step.
For example, if you have a step before your request that is a script, you can use something like:
context.setProperty("ProviderId", "SHL")
Then in your request, use:
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Of course, this doesn't buy you much by itself. There are few ways to vary what the context.setProperty("ProviderId", "SHL") line will set. You can create a collection and iterate over it using something like:
def providers = ['ABC', 'DEF', 'GHI', 'JKL']
providers.each() {
context.setProperty("ProviderId", it)
testRunner.runTestStepByName( "nameofteststep" )
}
Where "nameofteststep" is the name of the Soap Request test step. This might sound odd, but if you right click the test step and disable it, the groovy script will still be able to execute it but it will not run sequentially. By that I mean that the groovy script will run it 4 times, but it won't run a fifth time when the script is complete because it is after the script. Then you just need to keep in mind that each load test thread makes four requests, but I am pretty sure that the SoapUI statistics will take this into account for you... might want to keep an eye out for it, though.
Alternatively, you could check the 'threadIndex' and set a the context variable based on that. A bit like this here: Log ThreadCount.
You could also use a collection without a loop and increment an index that you save as a testcase property and send the string corresponding to the index.
Personally, I think the first way is the most straightforward but I can provide an example of the other ones if you like.
There is a simple way of doing this without writing a groovy script.
After creating a test case you should include the below test steps:
1-Data source
2-Request
3-Loop
Data source will read an excel file (or other data source methods such as XML, groovy, JDBC, gird .. however the excel is the simplest one).
You should include the datas (that you need to change within the request)
Within the test request you need the right click and select "get data" . please notice that your test request should be as below
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Then the last step is the "Loop" . This for returning to the first step until the data ends.
I hope this helps.

Limit of entries in Graph API 'home' results

I want to get stream entries from the last x days or weeks in the past. But when I call the news feed via Graph API with parameter 'limit' or 'until', I get entries from the last 48 hours only, no matter how high I define the parameter, also paging to the next pages is not possible, they are empty.
https://graph.facebook.com/me/home?access_token=...&limit=500
It seems that Facebook set up a limit (only in the 'home' feed). Does anybody know if there is a possibility to get more entries from a larger period of time? Or is it possible to get whitelisted from Facebook to receive more entries?
It seems /user/home has been deprecated use /user/feed instead
in response to your question the following are available in the graph explorer but i havent been able to find documentation on these. I would do more research on these.
/user/feed/?since=<value>
/user/feed/?until=<value>