卷曲请求什么都不返回

I'm trying to send request my api from curl using ajax call but it's not working.

<!-- MY FUNCTION that PERFORMs CURL REQUEST (This function is GETTING CALLED FROM ANOTHER FUNCTION THATS BEEN CALLED BY MY AJAX REQUEST)-->>

$ch = curl_init('http://myurl/add.json');
            curl_setopt($ch, CURLINFO_HEADER_OUT, true);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, POST); 
            if(!is_null($jsonString)) { //if json strng isn't null
               curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonString);  
            }       
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                'Content-Type: application/json',                                                                                
                'Content-Length: ' . strlen($jsonString),
                'signedInUserId: ' . USERID,
                'accessToken: ' . TOKEN)                                                                       
            );  
            $result = curl_exec($ch);
            curl_close($ch);

The problem here is I'm getting nothing in $result. Seems like curl request isn't working.

Can anyone tell me, what m I missing ? My site is hosted on amazon ec2 (ubuntu 13.10).

查看全部
dongnius85154
dongnius85154
2014/01/10 20:02
  • curl
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复