question

Upvotes
Accepted
1 2 3 4

strange result, every time returned data changes

Hi,

I have a php script connecting to opencalais api

but sometimes it works, somtimes it shows me errors. Everytime i refrech browser (one time i get good result without errors, another time i got errors) This is so strange.

the code is about sending string content from "string array" (containing few words) to opencalais

and i will juste get topics of each word in array. Just that, it's very strange

Thanks

intelligent-tagging-apiintelligent-taggingopen-calais-apisemantic-metadata-taggingphp
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Use "Ask an Expert" to contact Eyal.Kenigsvain

@memane

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,
AHS

@memane

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvotes
Accepted
101 1 0 1

Hi,

As you may expect, given the same input (identical), Calais' output should be the same.

If you can a run a simple test by repeating the same request with same input we may be able to investigate further (see that maybe some of the requests timeout). In addition, if you can review your HTTP request log (F12->network tab) you may see the actual errors returned from Calais which I hope amount to timeout in which case you will have to implement retries if you must have a response or skip if the response is not crucial.

At any rate, given the error message above a "null check" on the array will help you avoid this error.

Regards.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
101 1 0 1

Hello Memane,

As you justly expect seems like an easy task indeed...

So Let's try to figure out what is going wrong here:

  1. Please provide your php code snippet that makes the calls to the opencalais API
  2. Please provide a sample of error type you get in this process (if more than one kind of errors pleases provide all)

Please verify that you are providing the authentication Calais token and the rest of the header parameters as you can see from the API documentation and also from an earlier question in this forum.

At any rate, please provide 1 and 2 and we will try to resolve your issue ASAP.

Regards,

Eyal

FOR: @memane

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 2 3 4

Thanks, here are my 2 files in attachement:fcontext.zip

Everytime i refrech browser page, i get one of those 2 results (same script of course)

this one

or just this result without error:

Array
(
    [0] => Politics
)


r2.jpg (97.7 KiB)
fcontext.zip (2.6 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 2 3 4

Any ideas please ?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
101 1 0 1

Seems like for one of your inputs you get a Null array (Array # 2)

Try adding below condition as wrapper for foreach call.

if(is_array($opencalais_result)|| is_object($opencalais_result) 
{foreach... ...}
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 2 3 4

But, if you refrech the page in browser, you will get a good result without changing anything in script. so the probleme is not in array. Or maybe i did not understand you .

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@Eyal.Kenigsvain

Hi Eyal,

Could you please look into this client's response?

Thanks

AHS

Upvotes
1 0 0 0

Like this?



<?php

$array1 = array("a","b","c", "d","e","f","g","h", "i","j","k","l","m", "n","o","p","q","r");

$array2 = array();

for($i=0; $i<sizeof($array1); $i++) {
if($i==0||($i+1)%6==0) {
$array2[] = $array1[$i];
}
}

print_r($array2);
?>

Prints out: Array ( [0] => a [1] => f [2] => l [3] => r )

It loops through the first array and only adds to the second array if $i=0 (the first value) or if $i is divisible by 6 with a remainder of 0. Write my Dissertation Source(s): http://www.w3schools.com/PHP/php_operato.
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.