All Discussions Tagged 'PHP' - Build2024-03-28T10:30:33Zhttp://build.ning.com/forum/topic/listForTag?tag=PHP&feed=yes&xn_auth=noCreate a post with Ning PHP APItag:build.ning.com,2012-07-06:6308082:Topic:174282012-07-06T08:27:57.114ZLuís Gasparhttp://build.ning.com/profile/LuisGaspar
<p>Hi,</p>
<p>Did anyone achieve blog post creation using Ning PHP API?</p>
<p>With the folowing PHP…</p>
<p>Hi,</p>
<p>Did anyone achieve blog post creation using Ning PHP API?</p>
<p>With the folowing PHP code:</p>
<p>try {<br/> $args = array("author"=> "39azntkcdxn3r");<br/> $result = NingApi::instance()->user->fetch($args);<br/> print_r($result["success"]);<br/> <br/> $values = array (<br/> "title" => "Registro de peso",<br/> "publishStatus" => "publish",<br/> /*"publishTime" => "now",*/<br/> "publishTime" => "2012-07-03T00:00:00.000Z",<br/> "description" => "my first blog post",<br/> "visibility" => "me",<br/> "approved" => "true");<br/> <br/> $result = NingApi::instance()->blogPost->create($values);</p>
<p> print_r($result);<br/> <br/>}<br/>catch (Exception $e)<br/>{<br/> print_r($e);<br/>}</p>
<p>I get the following output:</p>
<p>1NingException Object<br/>(<br/> [httpStatus:NingException:private] =><br/> [ningCode:NingException:private] =><br/> [ningSubcode:NingException:private] =><br/> [ningTrace:NingException:private] =><br/> [message:protected] =><br/> [string:Exception:private] =><br/> [code:protected] => 0<br/> [file:protected] => /var/www/redemae/testeswidgets/public_html/ningapi/NingException.php<br/> [line:protected] => 56<br/> [trace:Exception:private] => Array<br/> (<br/> [0] => Array<br/> (<br/> [file] => /var/www/redemae/testeswidgets/public_html/ningapi/NingApi.php<br/> [line] => 233<br/> [function] => generate<br/> [class] => NingException<br/> [type] => ::<br/> [args] => Array<br/> (<br/> [0] =><br/> )</p>
<p>)</p>
<p>[1] => Array<br/> (<br/> [file] => /var/www/redemae/testeswidgets/public_html/ningapi/NingApi.php<br/> [line] => 240<br/> [function] => call<br/> [class] => NingApi<br/> [type] => -><br/> [args] => Array<br/> (<br/> [0] => BlogPost<br/> [1] => POST<br/> [2] => Array<br/> (<br/> [title] => Registro de peso<br/> [publishStatus] => publish<br/> [publishTime] => 2012-07-03T00:00:00.000Z<br/> [description] => my first blog post<br/> [visibility] => me<br/> [approved] => true<br/> )</p>
<p>[3] =><br/> [4] =><br/> )</p>
<p>)</p>
<p>[2] => Array<br/> (<br/> [file] => /var/www/redemae/testeswidgets/public_html/ningapi/NingObject.php<br/> [line] => 46<br/> [function] => post<br/> [class] => NingApi<br/> [type] => -><br/> [args] => Array<br/> (<br/> [0] => BlogPost<br/> [1] => Array<br/> (<br/> [title] => Registro de peso<br/> [publishStatus] => publish<br/> [publishTime] => 2012-07-03T00:00:00.000Z<br/> [description] => my first blog post<br/> [visibility] => me<br/> [approved] => true<br/> )</p>
<p>)</p>
<p>)</p>
<p>[3] => Array<br/> (<br/> [file] => /var/www/redemae/testeswidgets/public_html/ningapi/objects/NingBlogPost.php<br/> [line] => 21<br/> [function] => create<br/> [class] => NingObject<br/> [type] => -><br/> [args] => Array<br/> (<br/> [0] => Array<br/> (<br/> [title] => Registro de peso<br/> [publishStatus] => publish<br/> [publishTime] => 2012-07-03T00:00:00.000Z<br/> [description] => my first blog post<br/> [visibility] => me<br/> [approved] => true<br/> )</p>
<p>)</p>
<p>)</p>
<p>[4] => Array<br/> (<br/> [file] => /var/www/redemae/testeswidgets/public_html/createBlogPost.php<br/> [line] => 18<br/> [function] => create<br/> [class] => NingBlogPost<br/> [type] => -><br/> [args] => Array<br/> (<br/> [0] => Array<br/> (<br/> [title] => Registro de peso<br/> [publishStatus] => publish<br/> [publishTime] => 2012-07-03T00:00:00.000Z<br/> [description] => my first blog post<br/> [visibility] => me<br/> [approved] => true<br/> )</p>
<p>)</p>
<p>)</p>
<p>)</p>
<p>[previous:Exception:private] =><br/>)</p>
<p>Any help would be appreciated.</p> Problem with Ning API PHP librarytag:build.ning.com,2012-05-03:6308082:Topic:168162012-05-03T21:11:33.026ZBobby Parkerhttp://build.ning.com/profile/BobbyParker
<p>Hi,</p>
<p></p>
<p>The problem I'm having is when attempting to delete a photo (after getting the ID, and using $ningApi->photo->deleteById($id); I'm getting a "This feature has been disabled" error. I'm certain the ID/key is correct, since changing it results in an invalid key error.</p>
<p></p>
<p>I have access to the photos and can delete them from the main site, but I don't seem to be able to delete via the API.</p>
<p></p>
<p>Thoughts?</p>
<p>Hi,</p>
<p></p>
<p>The problem I'm having is when attempting to delete a photo (after getting the ID, and using $ningApi->photo->deleteById($id); I'm getting a "This feature has been disabled" error. I'm certain the ID/key is correct, since changing it results in an invalid key error.</p>
<p></p>
<p>I have access to the photos and can delete them from the main site, but I don't seem to be able to delete via the API.</p>
<p></p>
<p>Thoughts?</p> Getting logged in members Display Name or Email address via PHP APItag:build.ning.com,2011-07-28:6308082:Topic:74062011-07-28T00:02:51.212ZAlex Seymourhttp://build.ning.com/profile/AlexSeymour
<p>Hi,</p>
<p>I have managed to get the current logged in members email address, but think I have made it overly complicated. This is what I have done, my question is, is there a more efficient way to do it?</p>
<p> </p>
<p>In my ning network, I have added a text box and inside this, put the following HTML:</p>
<p><span style="font-family: courier new,courier; color: #0000ff;"><iframe id="testIframe" horizontalscrolling="no" allowtransparency="allowtransparency" style="border: none; width:…</span></p>
<p>Hi,</p>
<p>I have managed to get the current logged in members email address, but think I have made it overly complicated. This is what I have done, my question is, is there a more efficient way to do it?</p>
<p> </p>
<p>In my ning network, I have added a text box and inside this, put the following HTML:</p>
<p><span style="font-family: courier new,courier; color: #0000ff;"><iframe id="testIframe" horizontalscrolling="no" allowtransparency="allowtransparency" style="border: none; width: 500px; overflow-x: hidden;" name="testIframe" frameborder="0"></iframe></span></p>
<p><br/><span style="font-family: courier new,courier; color: #0000ff;"><script language="JavaScript" type="text/javascript">// <![CDATA[</span><br/><span style="font-family: courier new,courier; color: #0000ff;"> var author = ning.CurrentProfile.id;</span><br/><span style="font-family: courier new,courier; color: #0000ff;"> document.getElementById("testIframe").src = "http://xxx.com/test.php?author="+author;</span><br/><span style="font-family: courier new,courier; color: #0000ff;">// ]]></script></span></p>
<p> </p>
<p>Now in the file test.php I have:</p>
<p> </p>
<p><span style="font-family: courier new,courier; color: #0000ff;"><?php</span><br/><span style="font-family: courier new,courier; color: #0000ff;">require_once('ning-api-php/NingApi.php');</span><br/><br/><span style="font-family: courier new,courier; color: #0000ff;">//Get HTTP vars</span><br/><span style="font-family: courier new,courier; color: #0000ff;">$author = trim($_GET['author']);</span><br/><br/><span style="font-family: courier new,courier; color: #0000ff;">$args = array(</span><br/><span style="font-family: courier new,courier; color: #0000ff;"> "author" => $author</span><br/><span style="font-family: courier new,courier; color: #0000ff;">);</span><br/><br/><span style="font-family: courier new,courier; color: #0000ff;">$result = NingApi::instance()->user->fetch($args );</span><br/><br/><span style="font-family: courier new,courier; color: #0000ff;">print_r($result);</span><br/><span style="font-family: courier new,courier; color: #0000ff;">?></span></p>
<p> </p>
<p>This then gives me access to the logged in members email address, which I will then use to pull out of SalesForce some relevant data for that member and display it.</p>
<p>It works, but can I do this better?</p> How to update a photo using PHP?tag:build.ning.com,2011-04-28:6308082:Topic:33392011-04-28T07:13:42.947Zliyamahendra4http://build.ning.com/profile/liyamahendra4
<p>I have been trying to follow the API Documentation to update a photo using PHP.</p>
<p> </p>
<p>I went through the sample code blocks provide, but I really don't understand. May be its missing the detailed explanation. Its doing like</p>
<p>- creating $parts</p>
<p>- creating $newphoto</p>
<p>- changing $parts</p>
<p> </p>
<p>What I am doing is like:</p>
<p>When the user clicks on a photo, I get the "id" of the clicked photo. This gives information, that this particular photo needs to be…</p>
<p>I have been trying to follow the API Documentation to update a photo using PHP.</p>
<p> </p>
<p>I went through the sample code blocks provide, but I really don't understand. May be its missing the detailed explanation. Its doing like</p>
<p>- creating $parts</p>
<p>- creating $newphoto</p>
<p>- changing $parts</p>
<p> </p>
<p>What I am doing is like:</p>
<p>When the user clicks on a photo, I get the "id" of the clicked photo. This gives information, that this particular photo needs to be updated. Then I redirect the user to the page for uploading a new photo and set the obtained "id" for photo in hidden field.</p>
<p> </p>
<p>Then I don't know what to do exactly to update the photo.</p>
<p> </p>
<p>Is my approach wrong? Can anybody suggest me a solution with some sample code.</p>
<p> </p>
<p>Thanks.</p>