1

I hvae to call AT&T api for getting the userinfo using the following parameter

$a=array( 'Target'=>'UserPermissions',
         'Username'=>'isingh',
         'RightID'=>array("Param" => 1, "Param" => 6, "Param" => 17, "Param" 
 => 16, "Param" => 12,"Param" => 18));

How i will pass this in the curl

this is simple llok what i am doing
$a=array( 'Target'=>'GetUsers',
         'Origin'=>array('Param' => 1));
 $aa=http_build_query($a);
     $Url = "http://apiee.uc.att.com/apiee/api/api.asp?".$aa;
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$res = simplexml_load_string(curl_exec($ch));
  curl_close($ch);
 echo "<pre>"; print_r($res); echo "</pre>";

This code is working fine, there is no nested array in $a

3
  • What you have so far in curl code ? Commented Jul 2, 2012 at 7:09
  • You can't define the same key on multiple values in an array. Commented Jul 2, 2012 at 7:11
  • This array("Param" => 1, "Param" => 6, "Param" => 17, "Param" => 16, "Param" => 12,"Param" => 18) === array("Param" => 18) is TRUE Commented Jul 2, 2012 at 7:14

1 Answer 1

1

You should read the PHP.net cURL reference.

An easy Google Search lead me here curl_setopt.

On this page you'll find the CURLOPT_POST option that can be used with cURL.

You'll have to recursively go through each array element and set it as a cURL option with curl_setopt.

Sign up to request clarification or add additional context in comments.

2 Comments

some actuall links would be helpfull :-)
this is simple llok what i am doing $a=array( 'Target'=>'GetUsers', 'Origin'=>array('Param' => 1)); $aa=http_build_query($a); $Url = "apiee.uc.att.com/apiee/api/api.asp?".$aa; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $res = simplexml_load_string(curl_exec($ch)); curl_close($ch); echo "<pre>"; print_r($res); echo "</pre>"; This code is working fine, there is no nested array in $a

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.