开发者

Accessing task management API with PHP using cURL

I'm attempting to access an API for a task management system (Nozbe to be exact) that is outlined here: http://www.nozbe.com/api

If I go in my browser and access the URL it returns the correct json response: {"response":"644a40436"}

However, when I attempt to access this URL with cURL in PHP, it doesn't create the note like it would if I accessed it manually in my browser.

The normal method is outlined below: http://www.nozbe.com/api/newnote/name-test/body-test/project_id-c4ca1/context_id-c4ca1/key-1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6

$api_key                = "INSERTAPIKEYHERE";
$project_id             = "73d173457";

$eventtitle             = "Testing";

$descrip                = "This is a test";


$url                    = "http://www.nozbe.com/api/newnote/name-$eventtitle/body-$descrip/project_id-$project_id/key-$api_key";

echo "$url<br/><br/>";

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

// g开发者_JAVA百科rab URL and pass it to the browser
$response = curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

Does anyone have any advice or pointers as to why this isn't working? I know it's probably a pretty obscure API I'm attempting to access.


Note that the API says that the body and the like must be URL-encoded. Instead, you have spaces in your URL. Try running urlencode on the arguments before placing them into the URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜